Tiny (~200b) functional event emitter / pubsub.
It's tiny: no dependencies and only 190 bytes when gzipped (250b without).
npm install --save mitt
Mitt: Tiny (~200b) functional event emitter / pubsub.
Returns Mitt
Register an event handler for the given type.
Parameters
type
String Type of event to listen for, or"*"
for all eventshandler
Function Function to call in response to the given event
Remove an event handler for the given type.
Parameters
type
String Type of event to unregisterhandler
from, or"*"
handler
Function Handler function to remove
Invoke all handlers for the given type.
If present, "*"
handlers are invoked prior to type-matched handlers.
Parameters
type
String The event type to invokeevent
[Any] An event object, passed to each handler