happycode-gears-eventer
v1.0.12
Published
Simple Event / Subscribe for Gears env
Downloads
9
Maintainers
Readme
Eventer
Eventer (for Gears) is a minimal event subscriber / emitter
Installation
npm install happycode-gears-eventer
Usage
import { createAction, emit, subscribe } from 'happycode-gears-eventer'
or
const { createAction, subscribe, emit } = require('happycode-gears-eventer')
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}]`)
)