The
miis
is a tiny functional event subscriber and dispatcher.
This project need node and npm.
npm install miis --save
or
pnpm add miis --save
import miis from 'miis';
miis.subscribe("a", (...args) => {
console.log('a event call'); // a event call
console.log(...args); /// 1, 2, 3
});
miis.dispatch("a", 1, 2, 3);
You could unsubscribe the event lisenter with the result of subscribe.
import miis from 'miis';
const unsubscribe = miis.subscribe("a", () => {
console.log('a event call');
});
unsubscribe();
miis.dispatch("a"); // not work
Register an event listenter for the given name.
eventName
string | symbol Name of event to listen for.listenter
Function Function to call in response to given event
unsubscribe
Function Function to remove the listenter.
Invoke all handlers for the given name.
eventName
string | symbol Name of event to invoke for.