Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  improve dispatch performance if Signal doesnt have any listener. convert some tabs to spaces. bump version to 0.7.1
  • Loading branch information
millermedeiros committed Nov 29, 2011
2 parents 13a4c20 + 34cb78b commit 9ad9332
Show file tree
Hide file tree
Showing 16 changed files with 140 additions and 116 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.markdown
@@ -1,6 +1,12 @@
# JS-Signals Changelog #


## v0.7.1 (2011/11/29) ##

- Improve `dispatch()` performance if `Signal` doesn't have any listeners.



## v0.7.0 (2011/11/02) ##

### API changes ###
Expand Down
4 changes: 2 additions & 2 deletions dev/build/build.number
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Wed Nov 02 02:02:25 BRST 2011
build.number=242
#Tue Nov 29 12:33:24 BRST 2011
build.number=245
2 changes: 1 addition & 1 deletion dev/build/build.properties
Expand Up @@ -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.0
version.number = 0.7.1

dist.name = ${product.name}.js
dist.min.name = ${product.name}.min.js
28 changes: 17 additions & 11 deletions dev/src/Signal.js
Expand Up @@ -114,9 +114,9 @@

/**
* Add a listener to the signal.
* @param {Function} listener Signal handler function.
* @param {Object} [scope] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
* @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)
* @param {Function} listener Signal handler function.
* @param {Object} [scope] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
* @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)
* @return {SignalBinding} An Object representing the binding between the Signal and listener.
*/
add : function (listener, scope, priority) {
Expand All @@ -126,9 +126,9 @@

/**
* Add listener to the signal that should be removed after first execution (will be executed only once).
* @param {Function} listener Signal handler function.
* @param {Object} [scope] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
* @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)
* @param {Function} listener Signal handler function.
* @param {Object} [scope] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
* @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)
* @return {SignalBinding} An Object representing the binding between the Signal and listener.
*/
addOnce : function (listener, scope, priority) {
Expand All @@ -138,7 +138,7 @@

/**
* Remove a single listener from the dispatch queue.
* @param {Function} listener Handler function that should be removed.
* @param {Function} listener Handler function that should be removed.
* @return {Function} Listener handler function.
*/
remove : function (listener) {
Expand Down Expand Up @@ -181,21 +181,27 @@

/**
* Dispatch/Broadcast Signal to all listeners added to the queue.
* @param {...*} [params] Parameters that should be passed to each handler.
* @param {...*} [params] Parameters that should be passed to each handler.
*/
dispatch : function (params) {
if (! this.active) {
return;
}

var paramsArr = Array.prototype.slice.call(arguments),
bindings = this._bindings.slice(), //clone array in case add/remove items during dispatch
n = bindings.length;
n = this._bindings.length,
bindings;

if(this.memorize){
if (this.memorize) {
this._prevParams = paramsArr;
}

if (! n) {
//should come after memorize
return;
}

bindings = this._bindings.slice(); //clone array in case add/remove items during dispatch
this._shouldPropagate = true; //in case `halt` was called before dispatch or during the previous dispatch.

//execute all callbacks until end of the list or until a callback returns `false` or stops propagation
Expand Down
12 changes: 6 additions & 6 deletions dev/src/SignalBinding.js
Expand Up @@ -9,11 +9,11 @@
* @constructor
* @internal
* @name signals.SignalBinding
* @param {signals.Signal} signal Reference to Signal object that listener is currently bound to.
* @param {Function} listener Handler function bound to the signal.
* @param {boolean} isOnce If binding should be executed just once.
* @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
* @param {Number} [priority] The priority level of the event listener. (default = 0).
* @param {signals.Signal} signal Reference to Signal object that listener is currently bound to.
* @param {Function} listener Handler function bound to the signal.
* @param {boolean} isOnce If binding should be executed just once.
* @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
* @param {Number} [priority] The priority level of the event listener. (default = 0).
*/
function SignalBinding(signal, listener, isOnce, listenerContext, priority) {

Expand Down Expand Up @@ -71,7 +71,7 @@
/**
* 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
* @param {Array} [paramsArr] Array of parameters that should be passed to the listener
* @return {*} Value returned by the listener.
*/
execute : function (paramsArr) {
Expand Down
2 changes: 1 addition & 1 deletion dist/docs/files.html
Expand Up @@ -61,7 +61,7 @@ <h2><a href="symbols/src/_Users_millermedeiros_Projects__open_source_js-signals_
</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 Wed Nov 02 2011 02:02:31 GMT-0200 (BRST)
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Tue Nov 29 2011 12:33:31 GMT-0200 (BRST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion dist/docs/index.html
Expand Up @@ -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 Wed Nov 02 2011 02:02:31 GMT-0200 (BRST)
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Tue Nov 29 2011 12:33:30 GMT-0200 (BRST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion dist/docs/symbolindex.html
Expand Up @@ -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 Wed Nov 02 2011 02:02:31 GMT-0200 (BRST)
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Tue Nov 29 2011 12:33:31 GMT-0200 (BRST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion dist/docs/symbols/_global_.html
Expand Up @@ -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 Wed Nov 02 2011 02:02:31 GMT-0200 (BRST)
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Tue Nov 29 2011 12:33:30 GMT-0200 (BRST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion dist/docs/symbols/signals.Signal.html
Expand Up @@ -704,7 +704,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 Wed Nov 02 2011 02:02:31 GMT-0200 (BRST)
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Tue Nov 29 2011 12:33:30 GMT-0200 (BRST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion dist/docs/symbols/signals.SignalBinding.html
Expand Up @@ -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 Wed Nov 02 2011 02:02:31 GMT-0200 (BRST)
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Tue Nov 29 2011 12:33:30 GMT-0200 (BRST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion dist/docs/symbols/signals.html
Expand Up @@ -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 Wed Nov 02 2011 02:02:31 GMT-0200 (BRST)
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Tue Nov 29 2011 12:33:30 GMT-0200 (BRST)
| template based on Steffen Siering <a href="http://github.com/urso/jsdoc-simple">jsdoc-simple</a>.
</div>
</body>
Expand Down

0 comments on commit 9ad9332

Please sign in to comment.