life-cycle-hooks
A clean way to bind functions to events in custom code
Install
npm i --save life-cycle-hooks
Usage
Start by initializing a lifecycle object:
const LifeCycle = ;const lifecycle = ;
Then, to attach events:
lifecycle
To trigger all events bound to 'some_event':
lifecycle
Example use case
Suppose you have a websocket server, and you want to respond differently for mobile and desktop:
ws_server
You can then return lifecycle
, and in another part of your code, do the following:
lifecycle; lifecycle;