Provides a default main eventbus instance for backbone-esnext-events.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test/src
.babelrc
.esdocrc
.eslintignore
.eslintrc
.gitignore
.npmscriptrc
.travis.yml
AUTHORS.md
CHANGELOG.md
LICENSE
README.md
package.json

README.md

backbone-esnext-eventbus

NPM Documentation Code Style License Gitter

Build Status Coverage Dependency Status

For essential information pertaining to backbone-esnext please refer to backbone-esnext and the main issues forum.

backbone-esnext-eventbus provides a default instance of backbone-esnext-events which may serve as a main eventbus. Please refer to backbone-esnext-events for detailed documentation. The main impetus for a default main eventbus being easily imported across modules is to facilitate message passing between modules versus direct dependencies / method invocation.

It should be noted that this module only depends on backbone-esnext-events which has no other dependencies.

An example follows:

import mainEventbus from 'backbone-esnext-eventbus';

mainEventbus.on('fire:test', () => { console.log('Test Fired!'); return 42; }

mainEventbus.trigger('fire:test');  // Prints 'Test Fired'!

const value = mainEventbus.triggerSync('fire:test');  // Prints 'Test Fired' and returns '42'!

assert(value === 42);

and in an entirely separate module / source file:

import mainEventbus from 'backbone-esnext-eventbus';

const value = mainEventbus.triggerSync('fire:test');  // Prints 'Test Fired' and returns '42'!

assert(value === 42);

There are also four other alternate eventbus instances provided as named exports: auxEventbus, backboneEventbus, pluginEventbus and testEventbus.

These can be imported as follows:

import { auxEventbus }      from 'backbone-esnext-eventbus';
import { backboneEventbus } from 'backbone-esnext-eventbus';
import { pluginEventbus }   from 'backbone-esnext-eventbus';
import { testEventbus }     from 'backbone-esnext-eventbus';