🚀 Launch Week Day 3:Introducing Supply Chain Attack Campaigns Tracking.Learn More →
Socket
Book a DemoInstallSign in
Socket

ensemble

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ensemble

Event listener orchestration

latest
Source
npmnpm
Version
1.2.1
Version published
Maintainers
1
Created
Source

ensemble

NPM version build status Test coverage Dependency Status Downloads

Event listener orchestration. Makes it easy to bulk unbind listeners that were set withing a context. This is especially useful for unmounting listeners in React's componentWillUnmount lifecycle event.

Installation

$ npm i --save ensemble

Overview

var Emitter = require('events').EventEmitter;
var ensemble = require('ensemble');

/**
 * Wrap an event emitter.
 */

var emitter = ensemble(new Emitter);

/**
 * Attach listeners to the emitter.
 */

emitter.on('foo', function() {});

/**
 * Remove all listeners registered
 * in the wrapper from the emitter.
 */

emitter.removeListeners()

API

var emitter = ensemble(Emitter)

Wrap an event emitter in an ensemble object.

var Emitter = require('events').EventEmitter;
var ensemble = require('ensemble');

var myEmitter = ensemble(new Emitter);

.on(event, cb)

Attach an event listener to the wrapped emitter. Behaves identical to Node's built in listener function.

myEmitter.on('some_event', function(val) {
  console.log(val);
});

.removeListeners()

Remove all listeners that were attached within this context to the emitter.

myEmitter.removeListeners();

License

MIT © Yoshua Wuyts

Keywords

event

FAQs

Package last updated on 08 Oct 2014

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