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

Advantages over standard node events library? #175

Open
benjiwheeler opened this issue Feb 10, 2020 · 1 comment
Open

Advantages over standard node events library? #175

benjiwheeler opened this issue Feb 10, 2020 · 1 comment

Comments

@benjiwheeler
Copy link

Colleagues are asking whether to use pubsub-js or https://github.com/Gozala/events for a project.

I know pubsub-js is more extensive, but could the README clarify what pubsub-js can do that events can't? I understand that to use events similarly, you'd need to create a singleton instance, and from various places in your code, call the subscription and publishing/emitting functions on that instance.

@mroderick
Copy link
Owner

If you chose to use EventEmitter or similar as a singleton, you've basically created an implementation of publish/subscribe, very similar to PubSubJS. I think that both options are quite stable, so either would be a decent choice.

If you chose to go with EventEmitter, then I'd recommend creating the singleton in a file that can then be imported where needed, so you don't have to explicitly pass the singleton around. That's just a matter of convenience really.

There might be minor difference in features that make one solution more appealing than the other. Maybe one has a feature/method that you need, and the other doesn't.

If you feel like it, then a PR comparing PubSubJS with other solutions in a table, would be a nice addition to the README.

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