Minimal event emitter
const unemit = require("unemit");
const emitter = unemit();
const unsubscribe = emitter.on("type", data => {
console.log(data);
});
emitter.emit("type", { foo: "bar" });Returns an Emitter object
Emits an event of type type. Will call the handlers with handler(event).
Registers a handler for events of type type. Returns a function that removes the handler.
const unsubscribe = emitter.on("type", handler);
unsubscribe();Unlike other libraries, unevent will prevent registering the same handler twice for the same event type.
Removes a handler from events of type type.
Registers a handler for only the first event of type type. It's equivalent to:
function handler() {
emitter.off("type", handler);
}
emitter.on("type", handler);This library was inspired by mitt.