1.0.12 • Published 5 years ago

happycode-gears-eventer v1.0.12

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

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

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago