happycode-gears-eventer

1.0.12 • Public • Published

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}]`)
)

License

MIT

Package Sidebar

Install

npm i happycode-gears-eventer

Weekly Downloads

1

Version

1.0.12

License

MIT

Unpacked Size

7.73 kB

Total Files

7

Last publish

Collaborators

  • happycoder