@braintree/event-emitter
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -0,3 +1,7 @@ | ||
# 0.2.0 | ||
* Add `off` method | ||
# 0.1.0 | ||
* Initial release |
@@ -15,2 +15,9 @@ 'use strict'; | ||
EventEmitter.prototype.off = function (event, callback) { | ||
var eventCallbacks = this._events[event]; | ||
var indexOfCallback = eventCallbacks.indexOf(callback); | ||
eventCallbacks.splice(indexOfCallback, 1); | ||
}; | ||
EventEmitter.prototype._emit = function (event) { | ||
@@ -17,0 +24,0 @@ var i, args; |
{ | ||
"name": "@braintree/event-emitter", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "A simple event emitter.", | ||
@@ -5,0 +5,0 @@ "main": "event-emitter.js", |
@@ -41,2 +41,14 @@ # event-emitter | ||
### Unsubscribe from events | ||
```js | ||
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 | ||
@@ -43,0 +55,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4175
31
58