Event Message Bus
// main.js
import { default as bbus } from 'bbus'
bbus.on('SAY_SOMETHING', (message) => { console.log(message) })
// calls.js
import { default as bbus } from 'bbus'
bbus.emit('SAY_SOMETHING', 'Hello, world!')
// main.js
import { default as bbus } from 'bbus'
bbus.off('SAY_SOMETHING', *reference_for_function*)
You can use require() syntax too:
// main.js
const bbus = require('./bbus.js');
bbus.on('SAY_SOMETHING', (message) => { console.log(message) })