2.0.3 • Published 7 years ago

chirashi-event-emitter v2.0.3

Weekly downloads
17
License
MIT
Repository
github
Last release
7 years ago

chirashi

npm version Standard - JavaScript Style Guide Code Climate Issue Count Test Coverage Build Status

Intro

This is a tiny factory fonction to create a really simple event emitter.

Get started

Find API documentation on chirashijs.github.io/chirashi-event-emitter.

Quick view

Installation

Using npm / yarn (recommended)

yarn add chirashi-event-emitter

or

npm i --save chirashi-event-emitter

Now you can import methods in your project:

import EventEmitter from 'chirashi-event-emitter'

const emitter = EventEmitter()
const off = emitter.on('event', (foo, bar) => {
  console.log(foo, bar)
})

emitter.emit('event', 'foo', 'bar')
// logs: foo, bar

off()
emitter.emit('event', 'foo', 'bar')
// won't log anything

Standalone

You can download chirashi-event-emitter.js or chirashi-event-emitter.min.js and load it using a script tag. You can also use CDN version of those files from unpkg using the link https://unpkg.com/chirashi@latest/dist/chirashi-event-emitter.min.js. It'll create an instance of ChirashiEventEmitter on your window. Then use as following example

const emitter = ChirashiEventEmitter()

const off = emitter.on('event', (foo, bar) => {
  console.log(foo, bar)
})

emitter.emit('event', 'foo', 'bar')
// logs: foo, bar

off()
emitter.emit('event', 'foo', 'bar')
// won't log anything
2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago