text: Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var SignalBinding=exports.SignalBinding=function(){function SignalBinding(fn,thisArg){_classCallCheck(this,SignalBinding);this._fn=fn;this._thisArg=thisArg;this._next=this._prev=this._owner=null;}_createClass(SignalBinding,[{key:'detach',value:function detach(){if(this._owner===null)return false;this._owner.detach(this);return true;}}]);return SignalBinding;}();function _addSignalBinding(self,node){if(!self._head){self._head=node;self._tail=node;}else{self._tail._next=node;node._prev=self._tail;self._tail=node;}node._owner=self;return node;}var Signal=exports.Signal=function(){function Signal(){_classCallCheck(this,Signal);this._head=this._tail=undefined;}_createClass(Signal,[{key:'handlers',value:function handlers(){var exists=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var node=this._head;if(exists)return!!node;var ee=[];while(node){ee.push(node);node=node._next;}return ee;}},{key:'has',value:function has(node){if(!(node instanceof SignalBinding)){throw new Error('Signal#has(): First arg must be a SignalBinding object.');}return node._owner===this;}},{key:'dispatch',value:function dispatch(){var node=this._head;if(!node)return false;while(node){node._fn.apply(node._thisArg,arguments);node=node._next;}return true;}},{key:'add',value:function add(fn){var thisArg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(typeof fn!=='function'){throw new Error('Signal#add(): First arg must be a Function.');}return _addSignalBinding(this,new SignalBinding(fn,thisArg));}},{key:'detach',value:function detach(node){if(!(node instanceof SignalBinding)){throw new Error('Signal#detach(): First arg must be a SignalBinding object.');}if(node._owner!==this)return this;if(node._prev)node._prev._next=node._next;if(node._next)node._next._prev=node._prev;if(node===this._head){this._head=node._next;if(node._next===null){this._tail=null;}}else if(node===this._tail){this._tail=node._prev;this._tail._next=null;}node._owner=null;return this;}},{key:'detachAll',value:function detachAll(){var node=this._head;if(!node)return this;this._head=this._tail=null;while(node){node._owner=null;node=node._next;}return this;}}]);return Signal;}();