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 built-in window.dispatchEvent and window.dispatchCustomEvent? #178

Open
acherkashin opened this issue Mar 30, 2020 · 3 comments

Comments

@acherkashin
Copy link

No description provided.

@mroderick
Copy link
Owner

Did you come to any conclusions on this?
If so, would you share them in a pull request to improve the documentation?

@webketje
Copy link

One evident "advantage" of using PubSubJS is reducing cognitive load for apps and websites running Javascript on the front- and back-end. PubSubJS allows one to publish-subscribe in a unified way in both client and Node.JS. The vanilla alternative would be to use window.dispatchEvent with custom events on the client side, and EventEmitter in NodeJS.

@fatso83
Copy link

fatso83 commented May 25, 2023

Performance is obviously one thing, as you are restricted to between 60 (old IE) and 250 async updates per second with setTimeout. We could easily increase performance with one or two order of magnitude by replacing setTimeout with another macrotask scheduling mechanism(for instance usingpostMessagein the browser and nativenextTick` on Node).

An alternative take is the one taken by Emittery, which has no dependencies, and just relies on Promise for async dispatching. That's quite clever and very performant, but obviously not targetting ES3 😄

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

4 participants