Simple Event / Subscribe for Gears env
npm install happycode-gears-eventerEventer (for Gears) is a minimal event subscriber / emitter
``bash`
npm install happycode-gears-eventer
js
import { createAction, emit, subscribe } from 'happycode-gears-eventer'
`
or
`js
const { createAction, subscribe, emit } = require('happycode-gears-eventer')
``js
const sayHelloAction = createAction('SAYHELLO')subscribe('SAYHELLO', async (data) => {
await delay(5000)
console.log('Hello ' + data.name)
})
subscribe('SAYHELLO', (data) => {
console.log('Yo ' + data.name)
})
sayHelloAction.payload = {
name: "dude"
}
await emit(sayHelloAction,
() => console.log("All Subscriptions completed"),
(e) => consoe.log(
There was an Error - [${e.name} / ${e.message}])
)
``