2 var Emitter, Subscription,
3 __hasProp = {}.hasOwnProperty,
4 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6 Emitter = require('./emitter');
8 module.exports = Subscription = (function(_super) {
9 __extends(Subscription, _super);
11 Subscription.prototype.cancelled = false;
13 function Subscription(emitter, eventNames, handler) {
14 this.emitter = emitter;
15 this.eventNames = eventNames;
16 this.handler = handler;
19 Subscription.prototype.off = function() {
20 return this.dispose();
23 Subscription.prototype.dispose = function() {
24 var unsubscribe, _ref;
28 unsubscribe = (_ref = this.emitter.off) != null ? _ref : this.emitter.removeListener;
29 unsubscribe.call(this.emitter, this.eventNames, this.handler);
32 this.cancelled = true;
33 return this.emit('cancelled');