0.1.6 • Published 9 years ago

havana-event v0.1.6

Weekly downloads
1
License
ISC
Repository
github
Last release
9 years ago

Havana event

NPM version Build Status Dependency status

A simple publish/subscribe pattern.

How to install

npm install havana-event

How to use

At it's most basic:

import Event from 'havana-event';

const event = new Event();

event.subscribe( 'createWorld', () => {
  console.log( 'hello world' );
});

event.publish( 'createWorld' );

A slightly more complex example:

import Event from 'havana-event';

const event = new Event();

const token = event.subscribe( 'personBorn', data => {
  console.log( `hello ${data.name}` );
});

event.publish( 'personBorn', {
  'name': 'Colin'
});

event.unsubscribe( token );

ES2015+

Havana event is written using ES2015+ syntax.

However, by default this module will use an ES5 compatible file that has been compiled using Babel.

In the dist directory there are four files, the default is event.server.js. The default when using a client-side bundler that supports the browser field spec is event.browser.js.

Havana event currently requires the Babel polyfill. You are expected to supply this yourself. However, as a courtesy you will also find event.server.with-polyfill.js and event.browser.with-polyfill.js in the dist directory.

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago