combus ☎
A JavaScript browser event based communication BUS
Installation
# with npm npm i --save combus # with yarn yarn add combus
Examples
Creating a dependency injection system
// injector.js; const injectables = ; combus; combus; // injectables-stuff.js; { thisparam1 = param1; thisparam2 = param2; } { return thisparam1 + thisparam2; } { thisarr = arr; } { return thisarr; } combus; combus; // file-which-will-retrieve-the-injectable.js; Promiseall combus combus;
Communicating between bundles
Combus can be used to create a dialogue between different bundles (and different frameworks or libraries).
// bundle.1.js; const secret = 123; combus; // bumdle.2.js; combus; // bumdle.3.js; combus;
Creating a state machine
Combus could be useful to create a state machine
// state-machine.js; const state = todos: ; ; ; ; ; // your-logic.js; { return completed: false id name } { const todos = await payload; await ; await ; await ; await ; await ; await ; const remainingTodos = await payload; console; // [{ id: 2, name: 'baz', completed: true }];};