From c3b88810f80a74757c3b1e9ecd6066443096e390 Mon Sep 17 00:00:00 2001 From: Jonathan Buchanan Date: Thu, 23 Oct 2014 13:57:05 +0100 Subject: [PATCH 1/2] Allow a callback to be passed for the cancelCallback argument to firebaseRef.on() Not sure how to add a test to your suite for this, but have checked it at least works locally in react-hn against the Hacker News API, which errors when attempting to load delayed comments --- src/reactfire.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/reactfire.js b/src/reactfire.js index 474878c4..9bb1b9c5 100644 --- a/src/reactfire.js +++ b/src/reactfire.js @@ -22,17 +22,17 @@ var ReactFireMixin = { /* BINDING */ /*************/ /* Creates a binding between Firebase and the inputted bind variable as an array */ - bindAsArray: function(firebaseRef, bindVar) { - this._bind(firebaseRef, bindVar, true); + bindAsArray: function(firebaseRef, bindVar, cancelCallback) { + this._bind(firebaseRef, bindVar, cancelCallback, true); }, /* Creates a binding between Firebase and the inputted bind variable as an object */ - bindAsObject: function(firebaseRef, bindVar) { - this._bind(firebaseRef, bindVar, false); + bindAsObject: function(firebaseRef, bindVar, cancelCallback) { + this._bind(firebaseRef, bindVar, cancelCallback, false); }, /* Creates a binding between Firebase and the inputted bind variable as either an array or object */ - _bind: function(firebaseRef, bindVar, bindAsArray) { + _bind: function(firebaseRef, bindVar, cancelCallback, bindAsArray) { this._validateBindVar(bindVar); var errorMessage, errorCode; @@ -61,7 +61,7 @@ var ReactFireMixin = { newState[bindVar] = dataSnapshot.val(); } this.setState(newState); - }.bind(this)); + }.bind(this), cancelCallback); }, /* Removes the binding between Firebase and the inputted bind variable */ From 060b29fb9cd6ba906710a4d2984759f2beb7f594 Mon Sep 17 00:00:00 2001 From: Jonathan Buchanan Date: Sun, 26 Oct 2014 19:21:05 +0000 Subject: [PATCH 2/2] Added new argument to _bind() test --- tests/specs/reactfire.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/specs/reactfire.spec.js b/tests/specs/reactfire.spec.js index d769db58..a9d6ce2c 100644 --- a/tests/specs/reactfire.spec.js +++ b/tests/specs/reactfire.spec.js @@ -470,8 +470,8 @@ describe("ReactFireMixin Tests:", function() { componentWillMount: function() { var _this = this; - expect(function() { _this._bind(firebaseRef, "items", true); }).not.toThrow(); - expect(function() { _this._bind(firebaseRef, "items", false); }).not.toThrow(); + expect(function() { _this._bind(firebaseRef, "items", function() {}, true); }).not.toThrow(); + expect(function() { _this._bind(firebaseRef, "items", function() {}, false); }).not.toThrow(); }, render: function() {