[Pkg-javascript-commits] [backbone] 201/281: Documentation for Backbone.Events
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 17:02:12 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.9.0
in repository backbone.
commit 920d0471455808e1ef5f4a490465052fbfb3bceb
Author: Brad Dunbar <dunbarb2 at gmail.com>
Date: Fri Jan 13 17:16:05 2012 -0500
Documentation for Backbone.Events
---
backbone.js | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/backbone.js b/backbone.js
index 0e7cd63..718c056 100644
--- a/backbone.js
+++ b/backbone.js
@@ -75,8 +75,11 @@
on : function(events, callback, context) {
var ev;
events = events.split(/\s+/);
+ var calls = this._callbacks || (this._callbacks = {});
while (ev = events.shift()) {
- var calls = this._callbacks || (this._callbacks = {});
+ // Create an immutable callback list, allowing traversal during
+ // modification. The tail is an empty object that will always be used
+ // as the next node.
var list = calls[ev] || (calls[ev] = {});
var tail = list.tail || (list.tail = list.next = {});
tail.callback = callback;
@@ -99,6 +102,7 @@
node = calls[ev];
delete calls[ev];
if (!callback || !node) continue;
+ // Create a new list, omitting the indicated event/context pairs.
while ((node = node.next) && node.next) {
if (node.callback === callback &&
(!context || node.context === context)) continue;
@@ -118,11 +122,13 @@
events.unshift('all');
events.push(null);
if (!(calls = this._callbacks)) return this;
+ // Save references to the current head, tail, & args.
while (event = events.shift()) {
if (!(node = calls[event])) continue;
args = event == 'all' ? arguments : slice.call(arguments, 1);
events.push({next: node.next, tail: node.tail, args: args});
}
+ // Traverse each list, stopping when the saved tail is reached.
while (node = events.pop()) {
tail = node.tail;
args = node.args;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git
More information about the Pkg-javascript-commits
mailing list