Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improve remove() and has() to work with multiple contexts. closes #40

  • Loading branch information...
commit ad134845d6d66435828912bc1837813c538c6237 1 parent 34c9ae6
@millermedeiros authored
View
8 CHANGELOG.markdown
@@ -1,6 +1,14 @@
# JS-Signals Changelog #
+## v0.7.3 (2012/02/02) ##
+
+### Fixes ###
+
+ - `remove()` and `has()` now accepts the `context` as second argument. (#40)
+
+
+
## v0.7.2 (2012/01/12) ##
### Fixes ###
View
4 dev/build/build.number
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
-#Thu Jan 12 22:39:15 BRST 2012
-build.number=249
+#Thu Feb 02 10:20:14 BRST 2012
+build.number=252
View
2  dev/build/build.properties
@@ -9,7 +9,7 @@ jsdoc-toolkit.dir = ${build.dir}/jsdoc-toolkit
jslint.jar = ${build.dir}/jslint4java/jslint4java-1.4.6.jar
product.name = signals
-version.number = 0.7.2
+version.number = 0.7.3
dist.name = ${product.name}.js
dist.min.name = ${product.name}.min.js
View
22 dev/src/Signal.js
@@ -57,10 +57,10 @@
*/
_registerListener : function (listener, isOnce, listenerContext, priority) {
- var prevIndex = this._indexOfListener(listener),
+ var prevIndex = this._indexOfListener(listener, listenerContext),
binding;
- if (prevIndex !== -1 && this._bindings[prevIndex].context === listenerContext) {
+ if (prevIndex !== -1) {
binding = this._bindings[prevIndex];
if (binding.isOnce() !== isOnce) {
throw new Error('You cannot add'+ (isOnce? '' : 'Once') +'() then add'+ (!isOnce? '' : 'Once') +'() the same listener without removing the relationship first.');
@@ -93,10 +93,12 @@
* @return {number}
* @private
*/
- _indexOfListener : function (listener) {
- var n = this._bindings.length;
+ _indexOfListener : function (listener, context) {
+ var n = this._bindings.length,
+ cur;
while (n--) {
- if (this._bindings[n]._listener === listener) {
+ cur = this._bindings[n];
+ if (cur._listener === listener && cur.context === context) {
return n;
}
}
@@ -106,10 +108,11 @@
/**
* Check if listener was attached to Signal.
* @param {Function} listener
+ * @param {Object} [context]
* @return {boolean} if Signal has the specified listener.
*/
- has : function (listener) {
- return this._indexOfListener(listener) !== -1;
+ has : function (listener, context) {
+ return this._indexOfListener(listener, context) !== -1;
},
/**
@@ -139,12 +142,13 @@
/**
* Remove a single listener from the dispatch queue.
* @param {Function} listener Handler function that should be removed.
+ * @param {Object} [context] Execution context (since you can add the same handler multiple times if executing in a different context).
* @return {Function} Listener handler function.
*/
- remove : function (listener) {
+ remove : function (listener, context) {
validateListener(listener, 'remove');
- var i = this._indexOfListener(listener);
+ var i = this._indexOfListener(listener, context);
if (i !== -1) {
this._bindings[i]._destroy(); //no reason to a SignalBinding exist if it isn't attached to a signal
this._bindings.splice(i, 1);
View
2  dev/src/SignalBinding.js
@@ -92,7 +92,7 @@
* @return {Function|null} Handler function bound to the signal or `null` if binding was previously detached.
*/
detach : function () {
- return this.isBound()? this._signal.remove(this._listener) : null;
+ return this.isBound()? this._signal.remove(this._listener, this.context) : null;
},
/**
View
59 dev/tests/src/01.js
@@ -1228,6 +1228,65 @@ YUI().use('node', 'console', 'test', function (Y){
s.dispatch();
},
+ testRemoveDiffContext : function(){
+ var s = this.signal;
+
+ var l1 = function(){Y.Assert.fail();};
+ var obj = {};
+
+ var b1 = s.add(l1);
+ var b2 = s.add(l1, obj);
+ Y.Assert.areSame(2, s.getNumListeners());
+
+ Y.Assert.isUndefined(b1.context);
+ Y.Assert.areSame(l1, b1.getListener());
+ Y.Assert.areSame(obj, b2.context);
+ Y.Assert.areSame(l1, b2.getListener());
+
+ s.remove(l1, obj);
+
+ Y.Assert.isUndefined(b2.context);
+ Y.Assert.isUndefined(b2.getListener());
+
+ Y.Assert.isUndefined(b1.context);
+ Y.Assert.areSame(l1, b1.getListener());
+
+ Y.Assert.areSame(1, s.getNumListeners());
+ s.remove(l1);
+ Y.Assert.areSame(0, s.getNumListeners());
+ s.dispatch();
+ },
+
+ testRemoveDiffContext2 : function(){
+ var s = this.signal;
+
+ var l1 = function(){Y.Assert.fail();};
+ var obj = {};
+
+ var b1 = s.add(l1);
+ var b2 = s.add(l1, obj);
+ Y.Assert.areSame(2, s.getNumListeners());
+
+ Y.Assert.isUndefined(b1.context);
+ Y.Assert.areSame(l1, b1.getListener());
+ Y.Assert.areSame(obj, b2.context);
+ Y.Assert.areSame(l1, b2.getListener());
+
+ s.remove(l1);
+
+ Y.Assert.isUndefined(b1.context);
+ Y.Assert.isUndefined(b1.getListener());
+
+ Y.Assert.areSame(obj, b2.context);
+ Y.Assert.areSame(l1, b2.getListener());
+
+ Y.Assert.areSame(1, s.getNumListeners());
+ s.remove(l1, obj);
+ Y.Assert.areSame(0, s.getNumListeners());
+ s.dispatch();
+ },
+
+
//----------------- Memorize ----------------------------//
testMemorize : function(){
View
2  dist/docs/files.html
@@ -61,7 +61,7 @@ <h1 class="classTitle">File Index</h1>
</div>
<div class="fineprint" style="clear:both;text-align:center">
- Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Thu Jan 12 2012 22:39:23 GMT-0200 (BRST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Thu Feb 02 2012 10:20:21 GMT-0200 (BRST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
View
2  dist/docs/index.html
@@ -85,7 +85,7 @@ <h1 class="classTitle">Class Index</h1>
</div>
<div class="fineprint" style="clear:both;text-align:center">
- Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Thu Jan 12 2012 22:39:23 GMT-0200 (BRST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Thu Feb 02 2012 10:20:21 GMT-0200 (BRST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
View
2  dist/docs/symbolindex.html
@@ -314,7 +314,7 @@ <h1 id="classTitle">Symbol Index</h1>
</div>
<div class="fineprint" style="clear:both;text-align:center">
- Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Thu Jan 12 2012 22:39:23 GMT-0200 (BRST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Thu Feb 02 2012 10:20:21 GMT-0200 (BRST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
View
2  dist/docs/symbols/_global_.html
@@ -101,7 +101,7 @@ <h1 class="classTitle">
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both;text-align:center">
- Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Thu Jan 12 2012 22:39:23 GMT-0200 (BRST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Thu Feb 02 2012 10:20:20 GMT-0200 (BRST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
View
18 dist/docs/symbols/signals.Signal.html
@@ -547,7 +547,7 @@ <h1 class="classTitle">
<div class="modifiers">
</div>
<span class="light">{boolean}</span>
- <b>has</b>(listener)
+ <b>has</b>(listener, context)
</div>
<div class="description">
@@ -568,6 +568,12 @@ <h1 class="classTitle">
</dt>
<dd></dd>
+ <dt>
+ <span class="light fixedFont">{Object}</span> <b>context</b>
+ <i>Optional</i>
+ </dt>
+ <dd></dd>
+
</dl>
@@ -592,7 +598,7 @@ <h1 class="classTitle">
<div class="modifiers">
</div>
<span class="light">{Function}</span>
- <b>remove</b>(listener)
+ <b>remove</b>(listener, context)
</div>
<div class="description">
@@ -613,6 +619,12 @@ <h1 class="classTitle">
</dt>
<dd>Handler function that should be removed.</dd>
+ <dt>
+ <span class="light fixedFont">{Object}</span> <b>context</b>
+ <i>Optional</i>
+ </dt>
+ <dd>Execution context (since you can add the same handler multiple times if executing in a different context).</dd>
+
</dl>
@@ -704,7 +716,7 @@ <h1 class="classTitle">
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both;text-align:center">
- Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Thu Jan 12 2012 22:39:23 GMT-0200 (BRST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Thu Feb 02 2012 10:20:20 GMT-0200 (BRST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
View
2  dist/docs/symbols/signals.SignalBinding.html
@@ -526,7 +526,7 @@ <h1 class="classTitle">
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both;text-align:center">
- Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Thu Jan 12 2012 22:39:23 GMT-0200 (BRST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Thu Feb 02 2012 10:20:20 GMT-0200 (BRST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
View
2  dist/docs/symbols/signals.html
@@ -179,7 +179,7 @@ <h1 class="classTitle">
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both;text-align:center">
- Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Thu Jan 12 2012 22:39:23 GMT-0200 (BRST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Thu Feb 02 2012 10:20:20 GMT-0200 (BRST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
View
322 dist/docs/symbols/src/_Users_millermedeiros_Projects__open_source_js-signals_dist_signals.js.html
@@ -12,7 +12,7 @@
<span class='line'> 5</span> * JS Signals &lt;http://millermedeiros.github.com/js-signals/>
<span class='line'> 6</span> * Released under the MIT license
<span class='line'> 7</span> * Author: Miller Medeiros
-<span class='line'> 8</span> * Version: 0.7.2 - Build: 248 (2012/01/12 10:39 PM)
+<span class='line'> 8</span> * Version: 0.7.3 - Build: 251 (2012/02/02 10:20 AM)
<span class='line'> 9</span> */</span><span class="WHIT">
<span class='line'> 10</span>
<span class='line'> 11</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">global</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
@@ -27,7 +27,7 @@
<span class='line'> 20</span> * @type String
<span class='line'> 21</span> * @const
<span class='line'> 22</span> */</span><span class="WHIT">
-<span class='line'> 23</span> </span><span class="WHIT"> </span><span class="NAME">VERSION</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'0.7.2'</span><span class="WHIT">
+<span class='line'> 23</span> </span><span class="WHIT"> </span><span class="NAME">VERSION</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'0.7.3'</span><span class="WHIT">
<span class='line'> 24</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 25</span>
<span class='line'> 26</span>
@@ -125,7 +125,7 @@
<span class='line'>118</span> * @return {Function|null} Handler function bound to the signal or `null` if binding was previously detached.
<span class='line'>119</span> */</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT"> </span><span class="NAME">detach</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>121</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.isBound</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">this._signal.remove</span><span class="PUNC">(</span><span class="NAME">this._listener</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>121</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.isBound</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">this._signal.remove</span><span class="PUNC">(</span><span class="NAME">this._listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.context</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>123</span>
<span class='line'>124</span> </span><span class="WHIT"> </span><span class="COMM">/**
@@ -228,10 +228,10 @@
<span class='line'>221</span> */</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT"> </span><span class="NAME">_registerListener</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">isOnce</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">listenerContext</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">priority</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>223</span>
-<span class='line'>224</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">prevIndex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this._indexOfListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
+<span class='line'>224</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">prevIndex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this._indexOfListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">listenerContext</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT"> </span><span class="NAME">binding</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>226</span>
-<span class='line'>227</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">prevIndex</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this._bindings</span><span class="PUNC">[</span><span class="NAME">prevIndex</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">context</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">listenerContext</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>227</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">prevIndex</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT"> </span><span class="NAME">binding</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this._bindings</span><span class="PUNC">[</span><span class="NAME">prevIndex</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>229</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">binding.isOnce</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">isOnce</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>230</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">'You cannot add'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">isOnce</span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Once'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'() then add'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">isOnce</span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Once'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'() the same listener without removing the relationship first.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
@@ -264,159 +264,163 @@
<span class='line'>257</span> * @return {number}
<span class='line'>258</span> * @private
<span class='line'>259</span> */</span><span class="WHIT">
-<span class='line'>260</span> </span><span class="WHIT"> </span><span class="NAME">_indexOfListener</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>261</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this._bindings.length</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>262</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>263</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this._bindings</span><span class="PUNC">[</span><span class="NAME">n</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">_listener</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">listener</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>264</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>265</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
-<span class='line'>266</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
-<span class='line'>267</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>268</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
-<span class='line'>269</span>
-<span class='line'>270</span> </span><span class="WHIT"> </span><span class="COMM">/**
-<span class='line'>271</span> * Check if listener was attached to Signal.
-<span class='line'>272</span> * @param {Function} listener
-<span class='line'>273</span> * @return {boolean} if Signal has the specified listener.
-<span class='line'>274</span> */</span><span class="WHIT">
-<span class='line'>275</span> </span><span class="WHIT"> </span><span class="NAME">has</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>276</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this._indexOfListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>277</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
-<span class='line'>278</span>
-<span class='line'>279</span> </span><span class="WHIT"> </span><span class="COMM">/**
-<span class='line'>280</span> * Add a listener to the signal.
-<span class='line'>281</span> * @param {Function} listener Signal handler function.
-<span class='line'>282</span> * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
-<span class='line'>283</span> * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
-<span class='line'>284</span> * @return {SignalBinding} An Object representing the binding between the Signal and listener.
-<span class='line'>285</span> */</span><span class="WHIT">
-<span class='line'>286</span> </span><span class="WHIT"> </span><span class="NAME">add</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">listenerContext</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">priority</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>287</span> </span><span class="WHIT"> </span><span class="NAME">validateListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'add'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>288</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this._registerListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">listenerContext</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">priority</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>289</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
-<span class='line'>290</span>
-<span class='line'>291</span> </span><span class="WHIT"> </span><span class="COMM">/**
-<span class='line'>292</span> * Add listener to the signal that should be removed after first execution (will be executed only once).
-<span class='line'>293</span> * @param {Function} listener Signal handler function.
-<span class='line'>294</span> * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
-<span class='line'>295</span> * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
-<span class='line'>296</span> * @return {SignalBinding} An Object representing the binding between the Signal and listener.
-<span class='line'>297</span> */</span><span class="WHIT">
-<span class='line'>298</span> </span><span class="WHIT"> </span><span class="NAME">addOnce</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">listenerContext</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">priority</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>299</span> </span><span class="WHIT"> </span><span class="NAME">validateListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'addOnce'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>300</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this._registerListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">listenerContext</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">priority</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>301</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
-<span class='line'>302</span>
-<span class='line'>303</span> </span><span class="WHIT"> </span><span class="COMM">/**
-<span class='line'>304</span> * Remove a single listener from the dispatch queue.
-<span class='line'>305</span> * @param {Function} listener Handler function that should be removed.
-<span class='line'>306</span> * @return {Function} Listener handler function.
-<span class='line'>307</span> */</span><span class="WHIT">
-<span class='line'>308</span> </span><span class="WHIT"> </span><span class="NAME">remove</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>309</span> </span><span class="WHIT"> </span><span class="NAME">validateListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'remove'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>310</span>
-<span class='line'>311</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this._indexOfListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>312</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>313</span> </span><span class="WHIT"> </span><span class="NAME">this._bindings</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">_destroy</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">//no reason to a SignalBinding exist if it isn't attached to a signal</span><span class="WHIT">
-<span class='line'>314</span> </span><span class="WHIT"> </span><span class="NAME">this._bindings.splice</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>315</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
-<span class='line'>316</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">listener</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>317</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
-<span class='line'>318</span>
-<span class='line'>319</span> </span><span class="WHIT"> </span><span class="COMM">/**
-<span class='line'>320</span> * Remove all listeners from the Signal.
-<span class='line'>321</span> */</span><span class="WHIT">
-<span class='line'>322</span> </span><span class="WHIT"> </span><span class="NAME">removeAll</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>323</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this._bindings.length</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>324</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>325</span> </span><span class="WHIT"> </span><span class="NAME">this._bindings</span><span class="PUNC">[</span><span class="NAME">n</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">_destroy</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>326</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
-<span class='line'>327</span> </span><span class="WHIT"> </span><span class="NAME">this._bindings.length</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>328</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
-<span class='line'>329</span>
-<span class='line'>330</span> </span><span class="WHIT"> </span><span class="COMM">/**
-<span class='line'>331</span> * @return {number} Number of listeners attached to the Signal.
-<span class='line'>332</span> */</span><span class="WHIT">
-<span class='line'>333</span> </span><span class="WHIT"> </span><span class="NAME">getNumListeners</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>334</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this._bindings.length</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>335</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
-<span class='line'>336</span>
-<span class='line'>337</span> </span><span class="WHIT"> </span><span class="COMM">/**
-<span class='line'>338</span> * Stop propagation of the event, blocking the dispatch to next listeners on the queue.
-<span class='line'>339</span> * &lt;p>&lt;strong>IMPORTANT:&lt;/strong> should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.&lt;/p>
-<span class='line'>340</span> * @see signals.Signal.prototype.disable
-<span class='line'>341</span> */</span><span class="WHIT">
-<span class='line'>342</span> </span><span class="WHIT"> </span><span class="NAME">halt</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>343</span> </span><span class="WHIT"> </span><span class="NAME">this._shouldPropagate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>344</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
-<span class='line'>345</span>
-<span class='line'>346</span> </span><span class="WHIT"> </span><span class="COMM">/**
-<span class='line'>347</span> * Dispatch/Broadcast Signal to all listeners added to the queue.
-<span class='line'>348</span> * @param {...*} [params] Parameters that should be passed to each handler.
-<span class='line'>349</span> */</span><span class="WHIT">
-<span class='line'>350</span> </span><span class="WHIT"> </span><span class="NAME">dispatch</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">params</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>351</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">this.active</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>352</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>353</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
-<span class='line'>354</span>
-<span class='line'>355</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">paramsArr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Array.prototype.slice.call</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
-<span class='line'>356</span> </span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this._bindings.length</span><span class="PUNC">,</span><span class="WHIT">
-<span class='line'>357</span> </span><span class="WHIT"> </span><span class="NAME">bindings</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>260</span> </span><span class="WHIT"> </span><span class="NAME">_indexOfListener</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">context</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>261</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this._bindings.length</span><span class="PUNC">,</span><span class="WHIT">
+<span class='line'>262</span> </span><span class="WHIT"> </span><span class="NAME">cur</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>263</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>264</span> </span><span class="WHIT"> </span><span class="NAME">cur</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this._bindings</span><span class="PUNC">[</span><span class="NAME">n</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>265</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">cur._listener</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">listener</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">cur.context</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">context</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>266</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>267</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
+<span class='line'>268</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
+<span class='line'>269</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>270</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
+<span class='line'>271</span>
+<span class='line'>272</span> </span><span class="WHIT"> </span><span class="COMM">/**
+<span class='line'>273</span> * Check if listener was attached to Signal.
+<span class='line'>274</span> * @param {Function} listener
+<span class='line'>275</span> * @param {Object} [context]
+<span class='line'>276</span> * @return {boolean} if Signal has the specified listener.
+<span class='line'>277</span> */</span><span class="WHIT">
+<span class='line'>278</span> </span><span class="WHIT"> </span><span class="NAME">has</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">context</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>279</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this._indexOfListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">context</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>280</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
+<span class='line'>281</span>
+<span class='line'>282</span> </span><span class="WHIT"> </span><span class="COMM">/**
+<span class='line'>283</span> * Add a listener to the signal.
+<span class='line'>284</span> * @param {Function} listener Signal handler function.
+<span class='line'>285</span> * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
+<span class='line'>286</span> * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
+<span class='line'>287</span> * @return {SignalBinding} An Object representing the binding between the Signal and listener.
+<span class='line'>288</span> */</span><span class="WHIT">
+<span class='line'>289</span> </span><span class="WHIT"> </span><span class="NAME">add</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">listenerContext</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">priority</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>290</span> </span><span class="WHIT"> </span><span class="NAME">validateListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'add'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>291</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this._registerListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">listenerContext</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">priority</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>292</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
+<span class='line'>293</span>
+<span class='line'>294</span> </span><span class="WHIT"> </span><span class="COMM">/**
+<span class='line'>295</span> * Add listener to the signal that should be removed after first execution (will be executed only once).
+<span class='line'>296</span> * @param {Function} listener Signal handler function.
+<span class='line'>297</span> * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
+<span class='line'>298</span> * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
+<span class='line'>299</span> * @return {SignalBinding} An Object representing the binding between the Signal and listener.
+<span class='line'>300</span> */</span><span class="WHIT">
+<span class='line'>301</span> </span><span class="WHIT"> </span><span class="NAME">addOnce</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">listenerContext</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">priority</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>302</span> </span><span class="WHIT"> </span><span class="NAME">validateListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'addOnce'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>303</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this._registerListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">listenerContext</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">priority</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>304</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
+<span class='line'>305</span>
+<span class='line'>306</span> </span><span class="WHIT"> </span><span class="COMM">/**
+<span class='line'>307</span> * Remove a single listener from the dispatch queue.
+<span class='line'>308</span> * @param {Function} listener Handler function that should be removed.
+<span class='line'>309</span> * @param {Object} [context] Execution context (since you can add the same handler multiple times if executing in a different context).
+<span class='line'>310</span> * @return {Function} Listener handler function.
+<span class='line'>311</span> */</span><span class="WHIT">
+<span class='line'>312</span> </span><span class="WHIT"> </span><span class="NAME">remove</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">context</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>313</span> </span><span class="WHIT"> </span><span class="NAME">validateListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'remove'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>314</span>
+<span class='line'>315</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this._indexOfListener</span><span class="PUNC">(</span><span class="NAME">listener</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">context</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>316</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>317</span> </span><span class="WHIT"> </span><span class="NAME">this._bindings</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">_destroy</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">//no reason to a SignalBinding exist if it isn't attached to a signal</span><span class="WHIT">
+<span class='line'>318</span> </span><span class="WHIT"> </span><span class="NAME">this._bindings.splice</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>319</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
+<span class='line'>320</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">listener</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>321</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
+<span class='line'>322</span>
+<span class='line'>323</span> </span><span class="WHIT"> </span><span class="COMM">/**
+<span class='line'>324</span> * Remove all listeners from the Signal.
+<span class='line'>325</span> */</span><span class="WHIT">
+<span class='line'>326</span> </span><span class="WHIT"> </span><span class="NAME">removeAll</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>327</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this._bindings.length</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>328</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>329</span> </span><span class="WHIT"> </span><span class="NAME">this._bindings</span><span class="PUNC">[</span><span class="NAME">n</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">_destroy</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>330</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
+<span class='line'>331</span> </span><span class="WHIT"> </span><span class="NAME">this._bindings.length</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>332</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
+<span class='line'>333</span>
+<span class='line'>334</span> </span><span class="WHIT"> </span><span class="COMM">/**
+<span class='line'>335</span> * @return {number} Number of listeners attached to the Signal.
+<span class='line'>336</span> */</span><span class="WHIT">
+<span class='line'>337</span> </span><span class="WHIT"> </span><span class="NAME">getNumListeners</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>338</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this._bindings.length</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>339</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
+<span class='line'>340</span>
+<span class='line'>341</span> </span><span class="WHIT"> </span><span class="COMM">/**
+<span class='line'>342</span> * Stop propagation of the event, blocking the dispatch to next listeners on the queue.
+<span class='line'>343</span> * &lt;p>&lt;strong>IMPORTANT:&lt;/strong> should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.&lt;/p>
+<span class='line'>344</span> * @see signals.Signal.prototype.disable
+<span class='line'>345</span> */</span><span class="WHIT">
+<span class='line'>346</span> </span><span class="WHIT"> </span><span class="NAME">halt</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>347</span> </span><span class="WHIT"> </span><span class="NAME">this._shouldPropagate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>348</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
+<span class='line'>349</span>
+<span class='line'>350</span> </span><span class="WHIT"> </span><span class="COMM">/**
+<span class='line'>351</span> * Dispatch/Broadcast Signal to all listeners added to the queue.
+<span class='line'>352</span> * @param {...*} [params] Parameters that should be passed to each handler.
+<span class='line'>353</span> */</span><span class="WHIT">
+<span class='line'>354</span> </span><span class="WHIT"> </span><span class="NAME">dispatch</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">params</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>355</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">this.active</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>356</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>357</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>358</span>
-<span class='line'>359</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.memorize</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>360</span> </span><span class="WHIT"> </span><span class="NAME">this._prevParams</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">paramsArr</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>361</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
+<span class='line'>359</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">paramsArr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Array.prototype.slice.call</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
+<span class='line'>360</span> </span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this._bindings.length</span><span class="PUNC">,</span><span class="WHIT">
+<span class='line'>361</span> </span><span class="WHIT"> </span><span class="NAME">bindings</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>362</span>
-<span class='line'>363</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>364</span> </span><span class="WHIT"> </span><span class="COMM">//should come after memorize</span><span class="WHIT">
-<span class='line'>365</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>366</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
-<span class='line'>367</span>
-<span class='line'>368</span> </span><span class="WHIT"> </span><span class="NAME">bindings</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this._bindings.slice</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">//clone array in case add/remove items during dispatch</span><span class="WHIT">
-<span class='line'>369</span> </span><span class="WHIT"> </span><span class="NAME">this._shouldPropagate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">//in case `halt` was called before dispatch or during the previous dispatch.</span><span class="WHIT">
-<span class='line'>370</span>
-<span class='line'>371</span> </span><span class="WHIT"> </span><span class="COMM">//execute all callbacks until end of the list or until a callback returns `false` or stops propagation</span><span class="WHIT">
-<span class='line'>372</span> </span><span class="WHIT"> </span><span class="COMM">//reverse loop since listeners with higher priority will be added at the end of the list</span><span class="WHIT">
-<span class='line'>373</span> </span><span class="WHIT"> </span><span class="KEYW">do</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">--</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">bindings</span><span class="PUNC">[</span><span class="NAME">n</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this._shouldPropagate</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">bindings</span><span class="PUNC">[</span><span class="NAME">n</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">execute</span><span class="PUNC">(</span><span class="NAME">paramsArr</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>374</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
-<span class='line'>375</span>
-<span class='line'>376</span> </span><span class="WHIT"> </span><span class="COMM">/**
-<span class='line'>377</span> * Forget memorized arguments.
-<span class='line'>378</span> * @see signals.Signal.memorize
-<span class='line'>379</span> */</span><span class="WHIT">
-<span class='line'>380</span> </span><span class="WHIT"> </span><span class="NAME">forget</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>381</span> </span><span class="WHIT"> </span><span class="NAME">this._prevParams</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>382</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
-<span class='line'>383</span>
-<span class='line'>384</span> </span><span class="WHIT"> </span><span class="COMM">/**
-<span class='line'>385</span> * Remove all bindings from signal and destroy any reference to external objects (destroy Signal object).
-<span class='line'>386</span> * &lt;p>&lt;strong>IMPORTANT:&lt;/strong> calling any method on the signal instance after calling dispose will throw errors.&lt;/p>
-<span class='line'>387</span> */</span><span class="WHIT">
-<span class='line'>388</span> </span><span class="WHIT"> </span><span class="NAME">dispose</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>389</span> </span><span class="WHIT"> </span><span class="NAME">this.removeAll</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>390</span> </span><span class="WHIT"> </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">this._bindings</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>391</span> </span><span class="WHIT"> </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">this._prevParams</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>392</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
-<span class='line'>393</span>
-<span class='line'>394</span> </span><span class="WHIT"> </span><span class="COMM">/**
-<span class='line'>395</span> * @return {string} String representation of the object.
-<span class='line'>396</span> */</span><span class="WHIT">
-<span class='line'>397</span> </span><span class="WHIT"> </span><span class="NAME">toString</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
-<span class='line'>398</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">'[Signal active:'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.active</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">' numListeners:'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.getNumListeners</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">']'</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>399</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
-<span class='line'>400</span>
-<span class='line'>401</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>402</span>
-<span class='line'>403</span>
-<span class='line'>404</span> </span><span class="WHIT"> </span><span class="COMM">//exports to multiple environments</span><span class="WHIT">
-<span class='line'>405</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">define</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">define.amd</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">//AMD</span><span class="WHIT">
-<span class='line'>406</span> </span><span class="WHIT"> </span><span class="NAME">define</span><span class="PUNC">(</span><span class="STRN">'signals'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">signals</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>407</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">module</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">module.exports</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">//node</span><span class="WHIT">
-<span class='line'>408</span> </span><span class="WHIT"> </span><span class="NAME">module.exports</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">signals</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>409</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">//browser</span><span class="WHIT">
-<span class='line'>410</span> </span><span class="WHIT"> </span><span class="COMM">//use string because of Google closure compiler ADVANCED_MODE</span><span class="WHIT">
-<span class='line'>411</span> </span><span class="WHIT"> </span><span class="NAME">global</span><span class="PUNC">[</span><span class="STRN">'signals'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">signals</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>412</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
-<span class='line'>413</span>
-<span class='line'>414</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
-<span class='line'>415</span> </span></pre></body></html>
+<span class='line'>363</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.memorize</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>364</span> </span><span class="WHIT"> </span><span class="NAME">this._prevParams</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">paramsArr</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>365</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
+<span class='line'>366</span>
+<span class='line'>367</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>368</span> </span><span class="WHIT"> </span><span class="COMM">//should come after memorize</span><span class="WHIT">
+<span class='line'>369</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>370</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
+<span class='line'>371</span>
+<span class='line'>372</span> </span><span class="WHIT"> </span><span class="NAME">bindings</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this._bindings.slice</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">//clone array in case add/remove items during dispatch</span><span class="WHIT">
+<span class='line'>373</span> </span><span class="WHIT"> </span><span class="NAME">this._shouldPropagate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">//in case `halt` was called before dispatch or during the previous dispatch.</span><span class="WHIT">
+<span class='line'>374</span>
+<span class='line'>375</span> </span><span class="WHIT"> </span><span class="COMM">//execute all callbacks until end of the list or until a callback returns `false` or stops propagation</span><span class="WHIT">
+<span class='line'>376</span> </span><span class="WHIT"> </span><span class="COMM">//reverse loop since listeners with higher priority will be added at the end of the list</span><span class="WHIT">
+<span class='line'>377</span> </span><span class="WHIT"> </span><span class="KEYW">do</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">--</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">bindings</span><span class="PUNC">[</span><span class="NAME">n</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this._shouldPropagate</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">bindings</span><span class="PUNC">[</span><span class="NAME">n</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">execute</span><span class="PUNC">(</span><span class="NAME">paramsArr</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>378</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
+<span class='line'>379</span>
+<span class='line'>380</span> </span><span class="WHIT"> </span><span class="COMM">/**
+<span class='line'>381</span> * Forget memorized arguments.
+<span class='line'>382</span> * @see signals.Signal.memorize
+<span class='line'>383</span> */</span><span class="WHIT">
+<span class='line'>384</span> </span><span class="WHIT"> </span><span class="NAME">forget</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>385</span> </span><span class="WHIT"> </span><span class="NAME">this._prevParams</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>386</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
+<span class='line'>387</span>
+<span class='line'>388</span> </span><span class="WHIT"> </span><span class="COMM">/**
+<span class='line'>389</span> * Remove all bindings from signal and destroy any reference to external objects (destroy Signal object).
+<span class='line'>390</span> * &lt;p>&lt;strong>IMPORTANT:&lt;/strong> calling any method on the signal instance after calling dispose will throw errors.&lt;/p>
+<span class='line'>391</span> */</span><span class="WHIT">
+<span class='line'>392</span> </span><span class="WHIT"> </span><span class="NAME">dispose</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>393</span> </span><span class="WHIT"> </span><span class="NAME">this.removeAll</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>394</span> </span><span class="WHIT"> </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">this._bindings</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>395</span> </span><span class="WHIT"> </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">this._prevParams</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>396</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
+<span class='line'>397</span>
+<span class='line'>398</span> </span><span class="WHIT"> </span><span class="COMM">/**
+<span class='line'>399</span> * @return {string} String representation of the object.
+<span class='line'>400</span> */</span><span class="WHIT">
+<span class='line'>401</span> </span><span class="WHIT"> </span><span class="NAME">toString</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
+<span class='line'>402</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">'[Signal active:'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.active</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">' numListeners:'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.getNumListeners</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">']'</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>403</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
+<span class='line'>404</span>
+<span class='line'>405</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>406</span>
+<span class='line'>407</span>
+<span class='line'>408</span> </span><span class="WHIT"> </span><span class="COMM">//exports to multiple environments</span><span class="WHIT">
+<span class='line'>409</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">define</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">define.amd</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">//AMD</span><span class="WHIT">
+<span class='line'>410</span> </span><span class="WHIT"> </span><span class="NAME">define</span><span class="PUNC">(</span><span class="STRN">'signals'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">signals</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>411</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">module</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">module.exports</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">//node</span><span class="WHIT">
+<span class='line'>412</span> </span><span class="WHIT"> </span><span class="NAME">module.exports</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">signals</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>413</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">//browser</span><span class="WHIT">
+<span class='line'>414</span> </span><span class="WHIT"> </span><span class="COMM">//use string because of Google closure compiler ADVANCED_MODE</span><span class="WHIT">
+<span class='line'>415</span> </span><span class="WHIT"> </span><span class="NAME">global</span><span class="PUNC">[</span><span class="STRN">'signals'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">signals</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>416</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
+<span class='line'>417</span>
+<span class='line'>418</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
+<span class='line'>419</span> </span></pre></body></html>
View
28 dist/signals.js
@@ -5,7 +5,7 @@
* JS Signals <http://millermedeiros.github.com/js-signals/>
* Released under the MIT license
* Author: Miller Medeiros
- * Version: 0.7.2 - Build: 248 (2012/01/12 10:39 PM)
+ * Version: 0.7.3 - Build: 251 (2012/02/02 10:20 AM)
*/
(function(global){
@@ -20,7 +20,7 @@
* @type String
* @const
*/
- VERSION : '0.7.2'
+ VERSION : '0.7.3'
};
@@ -118,7 +118,7 @@
* @return {Function|null} Handler function bound to the signal or `null` if binding was previously detached.
*/
detach : function () {
- return this.isBound()? this._signal.remove(this._listener) : null;
+ return this.isBound()? this._signal.remove(this._listener, this.context) : null;
},
/**
@@ -221,10 +221,10 @@
*/
_registerListener : function (listener, isOnce, listenerContext, priority) {
- var prevIndex = this._indexOfListener(listener),
+ var prevIndex = this._indexOfListener(listener, listenerContext),
binding;
- if (prevIndex !== -1 && this._bindings[prevIndex].context === listenerContext) {
+ if (prevIndex !== -1) {
binding = this._bindings[prevIndex];
if (binding.isOnce() !== isOnce) {
throw new Error('You cannot add'+ (isOnce? '' : 'Once') +'() then add'+ (!isOnce? '' : 'Once') +'() the same listener without removing the relationship first.');
@@ -257,10 +257,12 @@
* @return {number}
* @private
*/
- _indexOfListener : function (listener) {
- var n = this._bindings.length;
+ _indexOfListener : function (listener, context) {
+ var n = this._bindings.length,
+ cur;
while (n--) {
- if (this._bindings[n]._listener === listener) {
+ cur = this._bindings[n];
+ if (cur._listener === listener && cur.context === context) {
return n;
}
}
@@ -270,10 +272,11 @@
/**
* Check if listener was attached to Signal.
* @param {Function} listener
+ * @param {Object} [context]
* @return {boolean} if Signal has the specified listener.
*/
- has : function (listener) {
- return this._indexOfListener(listener) !== -1;
+ has : function (listener, context) {
+ return this._indexOfListener(listener, context) !== -1;
},
/**
@@ -303,12 +306,13 @@
/**
* Remove a single listener from the dispatch queue.
* @param {Function} listener Handler function that should be removed.
+ * @param {Object} [context] Execution context (since you can add the same handler multiple times if executing in a different context).
* @return {Function} Listener handler function.
*/
- remove : function (listener) {
+ remove : function (listener, context) {
validateListener(listener, 'remove');
- var i = this._indexOfListener(listener);
+ var i = this._indexOfListener(listener, context);
if (i !== -1) {
this._bindings[i]._destroy(); //no reason to a SignalBinding exist if it isn't attached to a signal
this._bindings.splice(i, 1);
View
12 dist/signals.min.js
@@ -3,11 +3,11 @@
JS Signals <http://millermedeiros.github.com/js-signals/>
Released under the MIT license
Author: Miller Medeiros
- Version: 0.7.2 - Build: 248 (2012/01/12 10:39 PM)
+ Version: 0.7.3 - Build: 251 (2012/02/02 10:20 AM)
*/
-(function(g){function f(a,b,c,h,d){this._listener=b;this._isOnce=c;this.context=h;this._signal=a;this._priority=d||0}function e(a,b){if(typeof a!=="function")throw Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b));}var d={VERSION:"0.7.2"};f.prototype={active:!0,params:null,execute:function(a){var b;this.active&&this._listener&&(a=this.params?this.params.concat(a):a,b=this._listener.apply(this.context,a),this._isOnce&&this.detach());return b},detach:function(){return this.isBound()?
-this._signal.remove(this._listener):null},isBound:function(){return!!this._signal&&!!this._listener},getListener:function(){return this._listener},_destroy:function(){delete this._signal;delete this._listener;delete this.context},isOnce:function(){return this._isOnce},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}};d.Signal=function(){this._bindings=[];this._prevParams=null};d.Signal.prototype={memorize:!1,_shouldPropagate:!0,
-active:!0,_registerListener:function(a,b,c,d){var e=this._indexOfListener(a);if(e!==-1&&this._bindings[e].context===c){if(a=this._bindings[e],a.isOnce()!==b)throw Error("You cannot add"+(b?"":"Once")+"() then add"+(!b?"":"Once")+"() the same listener without removing the relationship first.");}else a=new f(this,a,b,c,d),this._addBinding(a);this.memorize&&this._prevParams&&a.execute(this._prevParams);return a},_addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b]&&a._priority<=
-this._bindings[b]._priority);this._bindings.splice(b+1,0,a)},_indexOfListener:function(a){for(var b=this._bindings.length;b--;)if(this._bindings[b]._listener===a)return b;return-1},has:function(a){return this._indexOfListener(a)!==-1},add:function(a,b,c){e(a,"add");return this._registerListener(a,!1,b,c)},addOnce:function(a,b,c){e(a,"addOnce");return this._registerListener(a,!0,b,c)},remove:function(a){e(a,"remove");var b=this._indexOfListener(a);b!==-1&&(this._bindings[b]._destroy(),this._bindings.splice(b,
+(function(h){function g(a,b,c,d,e){this._listener=b;this._isOnce=c;this.context=d;this._signal=a;this._priority=e||0}function f(a,b){if(typeof a!=="function")throw Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b));}var e={VERSION:"0.7.3"};g.prototype={active:!0,params:null,execute:function(a){var b;this.active&&this._listener&&(a=this.params?this.params.concat(a):a,b=this._listener.apply(this.context,a),this._isOnce&&this.detach());return b},detach:function(){return this.isBound()?
+this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},getListener:function(){return this._listener},_destroy:function(){delete this._signal;delete this._listener;delete this.context},isOnce:function(){return this._isOnce},toString:function(){return"[SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}};e.Signal=function(){this._bindings=[];this._prevParams=null};e.Signal.prototype={memorize:!1,_shouldPropagate:!0,
+active:!0,_registerListener:function(a,b,c,d){var e=this._indexOfListener(a,c);if(e!==-1){if(a=this._bindings[e],a.isOnce()!==b)throw Error("You cannot add"+(b?"":"Once")+"() then add"+(!b?"":"Once")+"() the same listener without removing the relationship first.");}else a=new g(this,a,b,c,d),this._addBinding(a);this.memorize&&this._prevParams&&a.execute(this._prevParams);return a},_addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b]&&a._priority<=this._bindings[b]._priority);
+this._bindings.splice(b+1,0,a)},_indexOfListener:function(a,b){for(var c=this._bindings.length,d;c--;)if(d=this._bindings[c],d._listener===a&&d.context===b)return c;return-1},has:function(a,b){return this._indexOfListener(a,b)!==-1},add:function(a,b,c){f(a,"add");return this._registerListener(a,!1,b,c)},addOnce:function(a,b,c){f(a,"addOnce");return this._registerListener(a,!0,b,c)},remove:function(a,b){f(a,"remove");var c=this._indexOfListener(a,b);c!==-1&&(this._bindings[c]._destroy(),this._bindings.splice(c,
1));return a},removeAll:function(){for(var a=this._bindings.length;a--;)this._bindings[a]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(a){if(this.active){var b=Array.prototype.slice.call(arguments),c=this._bindings.length,d;if(this.memorize)this._prevParams=b;if(c){d=this._bindings.slice();this._shouldPropagate=!0;do c--;while(d[c]&&this._shouldPropagate&&d[c].execute(b)!==!1)}}},forget:function(){this._prevParams=
-null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};typeof define==="function"&&define.amd?define("signals",[],d):typeof module!=="undefined"&&module.exports?module.exports=d:g.signals=d})(this);
+null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};typeof define==="function"&&define.amd?define("signals",[],e):typeof module!=="undefined"&&module.exports?module.exports=e:h.signals=e})(this);
View
2  package.json
@@ -3,7 +3,7 @@
"description" : "Custom Event/Messaging System",
"keywords" : ["js-signals", "signals", "pub/sub", "event", "publish", "subscribe", "observer"],
"homepage" : "http://millermedeiros.github.com/js-signals/",
- "version" : "0.7.2",
+ "version" : "0.7.3",
"author" : {
"name" : "Miller Medeiros",
"url" : "http://blog.millermedeiros.com/"
Please sign in to comment.
Something went wrong with that request. Please try again.