@braintree/event-emitter

WebJar for @braintree/event-emitter

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

braintree__event-emitter
Last Version

Last Version

0.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

@braintree/event-emitter
WebJar for @braintree/event-emitter
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/braintree/event-emitter

Download braintree__event-emitter

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/braintree__event-emitter/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>braintree__event-emitter</artifactId>
    <version>0.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/braintree__event-emitter/
implementation 'org.webjars.npm:braintree__event-emitter:0.3.0'
// https://jarcasting.com/artifacts/org.webjars.npm/braintree__event-emitter/
implementation ("org.webjars.npm:braintree__event-emitter:0.3.0")
'org.webjars.npm:braintree__event-emitter:jar:0.3.0'
<dependency org="org.webjars.npm" name="braintree__event-emitter" rev="0.3.0">
  <artifact name="braintree__event-emitter" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='braintree__event-emitter', version='0.3.0')
)
libraryDependencies += "org.webjars.npm" % "braintree__event-emitter" % "0.3.0"
[org.webjars.npm/braintree__event-emitter "0.3.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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
org.webjars.npm

Braintree

Versions

Version
0.3.0