#164·mitt

Mitt - some problems

Author: lk101Created Jul 8, 2022Updated Oct 25, 2022
Labelsenhancementquestion

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

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

while the

javascript
emitter.emit("evt");

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

Also,

javascript
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

javascript
emitter.emit("evt");

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

Also,

mitt not supports

javascript
emitter.off(); // off all of the listeners.