A simple event bus inspired by redux-saga. Framework agnostic.
First, create an instance of the saga in your app root:
//saga.jsimport{createSaga}from'saga-lite';exportdefaultcreateSaga();
Now you may import your saga.js module, and handle/dispatch actions:
importsagafrom'./saga.js';saga.handle('MY_ACTION_TYPE',action=>{console.log('handling',action);});
importsagafrom'./saga.js';saga.dispatch({type:'MY_ACTION_TYPE',myActionParam:'foo'});
You may wait for an action dispatch by using "take":
importsagafrom'./saga.js';saga.handle('MY_ACTION_TYPE',asyncaction=>{constaction2=awaitsaga.take('MY_ACTION_TYPE_2');});