basic-events

1.1.0 • Public • Published

basic-events

A very basic event emitter with three methods: .on, .once and .emit.

usage

import events from 'basic-events'

const app = {}
events(app)
// or
const app = events()

.on()

const unsubscribe = app.on(`data`, console.log)
app.emit(`data`, `poof`)
// `poof`
unsubscribe()
app.emit(`data`, `wroom`)
// nothing

.once()

const unsubscribe = app.once(`start`, console.log)
app.emit(`start`, `running`)
// `running`
app.emit(`start`, `jumping`)
// nothing

Package Sidebar

Install

npm i basic-events

Weekly Downloads

0

Version

1.1.0

License

MIT

Last publish

Collaborators

  • rogerbf