Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why singleton? #31

Closed
wertlex opened this issue Feb 15, 2016 · 5 comments
Closed

Why singleton? #31

wertlex opened this issue Feb 15, 2016 · 5 comments

Comments

@wertlex
Copy link

wertlex commented Feb 15, 2016

How to deal with two nexmo accounts or several instances for different purposes?
Is it solution by design or am I missing something?

Why not just:

const myNexmo1 = new Nexmo(key1, secret1);
const myNexmo2 = new Nexmo(key2, secret2); 
@pvela
Copy link
Contributor

pvela commented Feb 15, 2016

Technically it doesn't have to be a singleton. I will plan on changing this in a future release. In the mean time below is the workaround for you to try.

var nexmo = require('EASYNEXMO');
var enexmo = require('easynexmo');
var dnexmo = require('EASYnexmo');
nexmo.initialize("key1","secret1",true);
enexmo.initialize("key2","secret2",true);
dnexmo.initialize("key3","secret3",true);

I dont personally like this but something to get you going while I get this change done.

@wertlex
Copy link
Author

wertlex commented Feb 16, 2016

@pvela any help required?

@leggetter
Copy link
Contributor

leggetter commented Apr 25, 2016

@pvela @wertlex - I've experimented in a branch that does a few things:

  1. Moves to ES2015 and uses Babel transpilation
  2. Moves towards a non-singleton API, but still uses the singleton within the Nexmo instance for now
  3. Makes a start towards having functions live on related namespaces as per Must be namespaced by concept in the WiP (work in progress) library spec https://github.com/Nexmo/client-library-specification/blob/master/SPECIFICATION.md#api-methods

Any thoughts on this? e.g.

  • Are we okay moving to ES2015?
  • Do we think taking an incremental approach to non singltons is a good approach? Will it avoid a big bang and thus big changes?

Edit: Here's the branch https://github.com/Nexmo/nexmo-node/tree/namespaces

@pvela
Copy link
Contributor

pvela commented Apr 27, 2016

I am ok to move to ES2015. Thats the future 👍 .
I started doing a big bang approach in the old repo, but didn't make much progress. Having thought about it and made some initial design I can say for sure that its a good idea to take an incremental approach.

@leggetter
Copy link
Contributor

We are moving away from the singleton approach. Closing this question as answered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants