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

PubSub instanceable #6

Closed
maltmann opened this issue Mar 14, 2012 · 4 comments
Closed

PubSub instanceable #6

maltmann opened this issue Mar 14, 2012 · 4 comments

Comments

@maltmann
Copy link

Two ways to access the PubSub component:

  • Singleton (already exist)
  • multiple instances like
    var event2 = new PubSub();
    
    
@mroderick
Copy link
Owner

PubSubJS can be compared to a message queue, there is no need to have more than one instance. Having more than one instance will create confusion and will be cumbersome, as you'd have to pass that instance around.

@semmel
Copy link

semmel commented Feb 3, 2014

Maybe I didn't get it, but

  • How should I deal with many instances of the same class which all publish similarly named events?
  • How do I avoid event name conflicts between remote parts in my app?

Why not give every publisher its own PubSub as suggested by @maltmann , instead of a global PubSub singleton?
I'll attempt to fork and make it instantiable, since it seems easy and straight forward.

Thanks for the nice lib anyway!
Semmel

semmel added a commit to semmel/PubSubJS that referenced this issue Feb 4, 2014
@KutnerUri
Copy link

@mroderick - while using a global singleton is clearly simpler and more convenient, having the option for specific instances is a good idea. For example, if there are a couple of apps in the same browser, etc.

so +1 for instantiation.

@mroderick
Copy link
Owner

@KutnerUri if that's your need, then you should be using a library that supports that. event emitter is a good choice.

Repository owner locked as resolved and limited conversation to collaborators Mar 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants