Permalink
Browse files

Merge branch 'release-0.4'

  • Loading branch information...
millermedeiros committed Nov 27, 2010
2 parents ef3c3ab + 1fa6a8a commit 80cce086e034aae160028dc46595a5367e6da2c4
View
@@ -1,6 +1,26 @@
# JS-Signals Changelog #
+
+## v0.4 (2010/11/27) ##
+
+### API changes ###
+
+ - Added:
+ - `SignalBinding.prototype.detach()`
+ - `SignalBinding.prototype.dispose()`
+
+### Test Changes ###
+
+ - Added test cases for `detach` and `dispose`.
+
+### Other ###
+
+ - Improved docs for a few methods.
+ - Added internal method `Signal.prototype._addBinding()`.
+
+
+
## v0.3 (2010/11/27) ##
### API changes ###
@@ -27,7 +47,8 @@
Added inline documentation to source codeand included an HTML version of the documentation together with distribution files.
-
+
+
## v0.2 (2010/11/26) ##
### API changes ###
@@ -56,6 +77,7 @@ Added inline documentation to source codeand included an HTML version of the doc
Small refactoring and code cleaning.
+
## v0.1 (2010/11/26) ##
- initial release, support of basic features.
View
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
-#Sat Nov 27 01:01:20 EST 2010
-build.number=56
+#Sat Nov 27 16:19:16 EST 2010
+build.number=65
@@ -6,6 +6,6 @@ docs.dir = ${dist.dir}/docs
jsdoc-toolkit.dir = ${build.dir}/jsdoc-toolkit
yuicompressor.jar = ${build.dir}/yuicompressor/yuicompressor-2.4.2.jar
product.name = js-signals
-version.number = 0.3
+version.number = 0.4
dist.name = ${product.name}.js
dist.min.name = ${product.name}.min.js
View
@@ -45,12 +45,20 @@
}
} else {
binding = new signals.SignalBinding(listener, isOnce, scope, this);
- this._bindings.push(binding);
+ this._addBinding(binding);
}
return binding;
},
+ /**
+ * @param {signals.SignalBinding} binding
+ * @private
+ */
+ _addBinding : function _addBinding(binding){
+ this._bindings.push(binding);
+ },
+
/**
* @param {Function} listener
* @return {int}
@@ -143,7 +151,7 @@
},
/**
- * Dispatch Signal to all listeners added to the queue.
+ * Dispatch/Broadcast Signal to all listeners added to the queue.
* @param {...*} params Parameters that should be passed to each handler.
*/
dispatch : function dispatch(params){
View
@@ -1,7 +1,7 @@
/**
- * Class that represents a Signal Binding.
- * <br />- Constructor probably won't need to be called by end-user.
+ * Object that represents a binding between a Signal and a listener function.
+ * <br />- Constructor shouldn't be called by regular user, no point on creating a new binding without a Signal.
* <br />- inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes.
* @author Miller Medeiros
* @constructor
@@ -50,16 +50,37 @@
/**
* Call listener passing arbitrary parameters.
+ * <p>If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.</p>
* @param {Array} paramsArr Array of parameters that should be passed to the listener
* @return {*} Value returned by the listener.
*/
execute : function execute(paramsArr){
if(this._isEnabled){
- if(this._isOnce) this._signal.remove(this.listener);
+ if(this._isOnce) this.detach();
return this.listener.apply(this.listenerScope, paramsArr);
}
},
+ /**
+ * Detach binding from signal.
+ * - alias to: mySignal.remove(myBinding.listener);
+ * @return {Function} Handler function binded to the signal.
+ */
+ detach : function detach(){
+ return this._signal.remove(this.listener);
+ },
+
+ /**
+ * Remove binding from signal and destroy any reference to external Objects (destroy SignalBinding object).
+ */
+ dispose : function dispose(){
+ this.detach();
+ //remove reference to all objects
+ delete this._signal;
+ delete this.listener;
+ delete this.listenerScope;
+ },
+
/**
* Disable SignalBinding, block listener execution. Listener will only be executed after calling `enable()`.
* @see signals.SignalBinding.enable()
@@ -70,7 +91,7 @@
/**
* Enable SignalBinding. Enable listener execution.
- * @see signals.SignalBinding.pause()
+ * @see signals.SignalBinding.disable()
*/
enable : function enable(){
this._isEnabled = true;
View
@@ -816,6 +816,27 @@ YUI().use('node', 'console', 'test', function (Y){
Y.Assert.areSame(b1, b2);
},
+ testBindingDetach : function(){
+ var s = this.signal;
+ var b1 = s.add(function(){
+ Y.Assert.fail();
+ });
+ Y.Assert.areSame(1, s.getNumListeners());
+ b1.detach();
+ Y.Assert.areSame(0, s.getNumListeners());
+ s.dispatch();
+ },
+
+ testBindingDispose : function(){
+ var s = this.signal;
+ var b1 = s.add(function(){});
+ Y.Assert.areSame(1, s.getNumListeners());
+ b1.dispose();
+ Y.Assert.areSame(0, s.getNumListeners());
+ Y.Assert.isUndefined(b1.listener);
+ Y.Assert.isUndefined(b1.listenerScope);
+ },
+
//------------------------ Remove ----------------------------------//
View
@@ -61,7 +61,7 @@ <h2><a href="symbols/src/D__Projetos_millermedeiros_js-signals_dist_js-signals.j
</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 Sat Nov 27 2010 01:01:23 GMT-0500 (EST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Nov 27 2010 16:19:19 GMT-0500 (EST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
View
@@ -85,7 +85,7 @@ <h2><a href="symbols/signals.SignalBinding.html">signals.SignalBinding</a></h2>
</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 Sat Nov 27 2010 01:01:23 GMT-0500 (EST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Nov 27 2010 16:19:19 GMT-0500 (EST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
View
@@ -106,6 +106,15 @@ <h1 id="classTitle">Symbol Index</h1>
</td>
</tr>
+ <tr class="symbolEntry">
+ <td class="symbolName">detach</td>
+ <td>
+
+ <a href="symbols/signals.SignalBinding.html#detach">signals.SignalBinding#detach</a>
+
+ </td>
+ </tr>
+
<tr class="symbolEntry">
<td class="symbolName">disable</td>
<td>
@@ -126,6 +135,15 @@ <h1 id="classTitle">Symbol Index</h1>
</td>
</tr>
+ <tr class="symbolEntry">
+ <td class="symbolName">dispose</td>
+ <td>
+
+ <a href="symbols/signals.SignalBinding.html#dispose">signals.SignalBinding#dispose</a>
+
+ </td>
+ </tr>
+
<tr class="symbolEntry">
<td class="symbolName">enable</td>
<td>
@@ -264,7 +282,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 Sat Nov 27 2010 01:01:23 GMT-0500 (EST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Nov 27 2010 16:19:19 GMT-0500 (EST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
@@ -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 Sat Nov 27 2010 01:01:23 GMT-0500 (EST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Nov 27 2010 16:19:19 GMT-0500 (EST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
@@ -329,7 +329,7 @@ <h1 class="classTitle">
</div>
<div class="description">
- <p>Dispatch Signal to all listeners added to the queue.</p>
+ <p>Dispatch/Broadcast Signal to all listeners added to the queue.</p>
</div>
@@ -605,7 +605,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 Sat Nov 27 2010 01:01:23 GMT-0500 (EST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Nov 27 2010 16:19:19 GMT-0500 (EST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
@@ -84,10 +84,18 @@ <h3>Fields</h3>
<h3>Methods</h3>
<ul>
+ <li class="fixedFont">
+ <a href="../symbols/signals.SignalBinding.html#detach">detach</a>
+ </li>
+
<li class="fixedFont">
<a href="../symbols/signals.SignalBinding.html#disable">disable</a>
</li>
+ <li class="fixedFont">
+ <a href="../symbols/signals.SignalBinding.html#dispose">dispose</a>
+ </li>
+
<li class="fixedFont">
<a href="../symbols/signals.SignalBinding.html#enable">enable</a>
</li>
@@ -148,8 +156,8 @@ <h1 class="classTitle">
</div>
<div class="description">
- <p>Class that represents a Signal Binding.
-<br />- Constructor probably won't need to be called by end-user.
+ <p>Object that represents a binding between a Signal and a listener function.
+<br />- Constructor shouldn't be called by regular user, no point on creating a new binding without a Signal.
<br />- inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes.</p>
<br /><i>Author: </i>Miller Medeiros.
</div>
@@ -262,6 +270,41 @@ <h1 class="classTitle">
Method Detail
</div>
+ <div class="member">
+ <a name="detach"> </a>
+ <div class="fixedFont">
+ <div class="modifiers">
+ </div>
+ <span class="light">{Function}</span>
+ <b>detach</b>()
+
+ </div>
+ <div class="description">
+ <p>Detach binding from signal.
+- alias to: mySignal.remove(myBinding.listener);</p>
+
+
+ </div>
+
+
+
+
+
+
+
+
+ <dl class="detailList">
+ <dt class="heading">Returns:</dt>
+
+ <dd><span class="light fixedFont">{Function}</span> Handler function binded to the signal.</dd>
+
+ </dl>
+
+
+
+
+ </div>
+
<div class="member">
<a name="disable"> </a>
<div class="fixedFont">
@@ -294,6 +337,33 @@ <h1 class="classTitle">
</dl>
+ </div>
+
+ <div class="member">
+ <a name="dispose"> </a>
+ <div class="fixedFont">
+ <div class="modifiers">
+ </div>
+
+ <b>dispose</b>()
+
+ </div>
+ <div class="description">
+ <p>Remove binding from signal and destroy any reference to external Objects (destroy SignalBinding object).</p>
+
+
+ </div>
+
+
+
+
+
+
+
+
+
+
+
</div>
<div class="member">
@@ -323,7 +393,7 @@ <h1 class="classTitle">
<dl class="detailList">
<dt class="heading">See:</dt>
- <dd>signals.SignalBinding.pause()</dd>
+ <dd>signals.SignalBinding.disable()</dd>
</dl>
@@ -341,6 +411,8 @@ <h1 class="classTitle">
</div>
<div class="description">
<p>Call listener passing arbitrary parameters.</p>
+
+<p>If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.</p>
</div>
@@ -489,7 +561,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 Sat Nov 27 2010 01:01:23 GMT-0500 (EST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Nov 27 2010 16:19:19 GMT-0500 (EST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
Oops, something went wrong.

0 comments on commit 80cce08

Please sign in to comment.