JEM
What is JEM?
JEM stands for **J**avaScript **E**vent**M**anager. It's a small tool for handling custom events across multiple modules.
JEM provides minimal functionality helping you to keep cleaner codebase with less dependencies.
How does it work?
Every event has a unique identifier - it's name. You can subscribe endless functions to an event. If the event gets emitted all subscribers will be called.
Getting started
Installation
npm i jemjs --save-dev
;
Reference
JEM.On(eventName, ...listener)
Subscribes one or multiple listeners to an event.
JEM;
Mutliple listeners can subscribe to On too.
JEM;
JEM.Once(eventName, ...listener)
Subscribes one or multiple listeners to an event. Listenery bound with Once will be dispatched after the first call.
JEM;
Multiple listeners can subscribe to Once too.
JEM;
JEM.Emit(eventName[, ...listenerArgs])
Calls all listeners subscribed to the specified event.
// Call all subscribers for the event "eventName" JEM; //Works with arguments too. JEM; //Even with a lot arguments JEM;
JEM.Dispatch
Removes a listener or a complete event.
JEM; // Removes the specified event. All listeners are gone. { return ++x; } JEM; //Removes this listener.
JEM.Clear
Removes all events (and all listeners).
JEM;
JEM.Isolate
Creates a new isolated JEM-scope. By default theres only one global JEM-scope. Isolated scopes provided the same functionality like the global JEM-scope except the Isolate function is not present.
const isolatedJEM = JEM;