Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit 411cff0

Browse files
bendruckeranantn
authored andcommitted
Make $on chainable
1 parent bb8fb3f commit 411cff0

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

angularfire.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,12 @@
341341
self._timeout(function() {
342342
callback();
343343
});
344-
return;
345-
}
346-
if (self._on.hasOwnProperty(type)) {
344+
} else if (self._on.hasOwnProperty(type)) {
347345
self._on[type].push(callback);
348346
} else {
349347
throw new Error("Invalid event type " + type + " specified");
350348
}
349+
return object;
351350
};
352351

353352
// Detach an event handler from a specified event type. If no callback

angularfire.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/e2e/test_chat.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ casper.then(function() {
126126
}, "Testing if $add, $set, $save and $remove return a promise");
127127
});
128128

129+
casper.then(function() {
130+
this.test.assertEval(function() {
131+
var empty = function() {};
132+
var obj = _scope.messages.$on('loaded', empty).$on('change', empty);
133+
return JSON.stringify(_scope.messages) == JSON.stringify(obj);
134+
}, "Testing chaining of $on method");
135+
});
136+
129137
casper.run(function() {
130138
this.test.done();
131139
});

0 commit comments

Comments
 (0)