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

Mitt - some problems #164

Open
lk101 opened this issue Jul 8, 2022 · 1 comment
Open

Mitt - some problems #164

lk101 opened this issue Jul 8, 2022 · 1 comment

Comments

@lk101
Copy link

lk101 commented Jul 8, 2022

I found some problems with mitt. Will these problems be considered in the future?

const emitter = mitt();
emitter.on("evt", () => {});
emitter.on("evt", () => { throw "some error." })
emitter.on("evt", () => { /** do something... */ })

while the

emitter.emit("evt");

happen, there is no chance to run the third callback.

Also,

emitter.on("evt", () => { emitter.off("evt") });
emitter.on("evt", () => { /** do something... */});
emitter.on("evt", () => { emitter.off("*") });
emitter.on("*", () => { /** do something... */});
emitter.on("*", () => { /** do something... */});
emitter.on("*", () => { /** do something... */});

while the

emitter.emit("evt");

happen, there is no chance to run the "*" callback, but can run the second "evt" callback.

Also,

mitt not supports

emitter.off(); // off all of the listeners.
@developit
Copy link
Owner

off() is only really supported by Vue IIRC, whereas this API is more in line with Node's EventEmitter.

The error propagation is a good point. I will have to check what Node does (I believe it propagates synchronously like Mitt).

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

No branches or pull requests

2 participants