Skip to content

yoshuawuyts/event-aggregate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

event-aggregate

NPM version build status Test coverage

An aggregator for your events. Funnels events through a single point, so not all of your code needs to attach listeners to every object. This approach is particularly good for handling error events by UI components.

Installation

$ npm i --save event-aggregate

Overview

var aggregate = require('event-aggregate');

module.exports = aggregate({
  error: [locationsStore, pathStore],
  change: [pathStore]
});

API

aggregate()

Initialize the event aggregator. Takes an {Object} config as an argument, which defines the event names as keys, and an array of emitters as the value.

When an event is received from an emitter, event-aggregate will emit the same event.

module.exports = aggregate({
  error: [myAsyncThing, myOtherAsyncThing],
  success: [myOtherAsyncThing],
  warning: [myAsyncthing]
});

// When 'myAsyncThing' emits an error, we will catch it,
// and emit the same error ourselves.

License

MIT © Yoshua Wuyts

About

Event multiplexer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published