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

Proliferation of global variables. #2

Closed
nrn opened this issue Dec 29, 2014 · 4 comments
Closed

Proliferation of global variables. #2

nrn opened this issue Dec 29, 2014 · 4 comments

Comments

@nrn
Copy link

nrn commented Dec 29, 2014

By adding each name space to global as it's own variable they all become available in every module by that name. Pretty unexpected behavior, and can return unexpected objects from the global name space.

Better to put them all on a single global object with a hard to mistakenly interact with name space. Something like:

var globalStore = global['sparkles@store']
if (!globalStore) globalStore =  global['sparkles@store'] = {}
// store all event emitters on globalStore
@phated
Copy link
Member

phated commented Dec 30, 2014

Thoughts on using a weakmap for this?

@phated
Copy link
Member

phated commented Dec 30, 2014

Nevermind, it's just a string reference.

@phated phated closed this as completed in 834e409 Dec 30, 2014
@phated
Copy link
Member

phated commented Dec 30, 2014

Thoughts on 834e409 ? Does it solve this?

@nrn
Copy link
Author

nrn commented Dec 30, 2014

Looks great, solves all my concerns.

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

2 participants