yaemit

2.0.0 • Public • Published

yaemit

TravisCI Coverage Dependencies Dev Dependencies npm version MIT license

Install

npm --save install yaemit

Example

Direct usage of Emitter:

import Emitter from 'yaemit'

const e = new Emitter()
const fn = (input) => console.log('hello', input)

e.on('event', fn)
e.emit('event', 'world')

Context binding for the event handler:

e.on('event', handler.bind(context))

Emitter can be extended:

class Hello extends Emitter {
  constructor() {
    this.on('event', this.hello)
  }

  hello(input) {
    console.log('hello', input)
  }
}

(new Hello()).emit('event', 'world')

Package Sidebar

Install

npm i yaemit

Weekly Downloads

2

Version

2.0.0

License

MIT

Last publish

Collaborators

  • kroogs