$ cnpm install @keystone/emitter
Example
import Emitter from '@keystone/emitter'
class Something extends Emitter {}
const something = new Something()
something.on('load', () => {
console.log('load event fired.')
})
Kind: Exported class
Emit an event.
Kind: instance method of Emitter
| Param | Type | Description |
|---|---|---|
| eventName | string | the event name to emit |
| ...args | * | args to pass to the event handler |
Register an event listener.
Kind: instance method of Emitter
| Param | Type | Description |
|---|---|---|
| eventName | string | the event name to watch |
| handler | function | the event handler |
Remove an event listener.
Kind: instance method of Emitter
| Param | Type | Description |
|---|---|---|
| eventName | string | the event name |
| handler | function | the event handler |
Copyright 2013 - present © cnpmjs.org | Home |