Skip to content

Commit 537a3bd

Browse files
author
Jacob Wenger
committed
Merge pull request #24 from insin/cancelCallback
Allow a callback to be passed for the cancelCallback argument to firebaseRef.on()
2 parents 248e60e + 060b29f commit 537a3bd

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/reactfire.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ var ReactFireMixin = {
2222
/* BINDING */
2323
/*************/
2424
/* Creates a binding between Firebase and the inputted bind variable as an array */
25-
bindAsArray: function(firebaseRef, bindVar) {
26-
this._bind(firebaseRef, bindVar, true);
25+
bindAsArray: function(firebaseRef, bindVar, cancelCallback) {
26+
this._bind(firebaseRef, bindVar, cancelCallback, true);
2727
},
2828

2929
/* Creates a binding between Firebase and the inputted bind variable as an object */
30-
bindAsObject: function(firebaseRef, bindVar) {
31-
this._bind(firebaseRef, bindVar, false);
30+
bindAsObject: function(firebaseRef, bindVar, cancelCallback) {
31+
this._bind(firebaseRef, bindVar, cancelCallback, false);
3232
},
3333

3434
/* Creates a binding between Firebase and the inputted bind variable as either an array or object */
35-
_bind: function(firebaseRef, bindVar, bindAsArray) {
35+
_bind: function(firebaseRef, bindVar, cancelCallback, bindAsArray) {
3636
this._validateBindVar(bindVar);
3737

3838
var errorMessage, errorCode;
@@ -61,7 +61,7 @@ var ReactFireMixin = {
6161
newState[bindVar] = dataSnapshot.val();
6262
}
6363
this.setState(newState);
64-
}.bind(this));
64+
}.bind(this), cancelCallback);
6565
},
6666

6767
/* Removes the binding between Firebase and the inputted bind variable */

tests/specs/reactfire.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,8 @@ describe("ReactFireMixin Tests:", function() {
470470
componentWillMount: function() {
471471
var _this = this;
472472

473-
expect(function() { _this._bind(firebaseRef, "items", true); }).not.toThrow();
474-
expect(function() { _this._bind(firebaseRef, "items", false); }).not.toThrow();
473+
expect(function() { _this._bind(firebaseRef, "items", function() {}, true); }).not.toThrow();
474+
expect(function() { _this._bind(firebaseRef, "items", function() {}, false); }).not.toThrow();
475475
},
476476

477477
render: function() {

0 commit comments

Comments
 (0)