Socket
Book a DemoInstallSign in
Socket

event-aggregate

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-aggregate

Funnels events through a single point, so not all of your code needs to attach listeners to every object.

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

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

Keywords

events

FAQs

Package last updated on 24 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts