Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@braintree/event-emitter

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@braintree/event-emitter

A simple event emitter.

  • 0.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
272K
increased by5.69%
Maintainers
1
Weekly downloads
 
Created
Source

event-emitter

A helper module for creating objects with event emitter capabilities.

Installation

npm

npm install --save @braintree/event-emitter

This module uses commonjs. You must use a build tool such as Browserify or Webpack to include it in your frontend project.

Usage

Creating an Object that Inherits from Event Emitter

var EventEmitter = require("@braintree/event-emitter");

function MyClass() {
  EventEmitter.call(this);
}

MyClass.prototype = EventEmitter.createChild(MyClass);

Listen for events

var obj = new MyClass();

obj.on("event-name", function (data) {
  console.log("called with", data.payload, "!");
});

obj._emit("event-name", { payload: "foo" }); // logs "called with foo!"

Unsubscribe from events

var obj = new MyClass();
var cb = function () {};

obj.on("event-name", cb);
obj.off("event-name", cb);

obj._emit("event-name", { payload: "foo" }); // cb is not called

Tests

npm test

FAQs

Package last updated on 10 Aug 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc