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

Commit 56dad61

Browse files
committed
Call .off('value') with a specific callback, fixes #171
1 parent e12392a commit 56dad61

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

angularfire.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ AngularFire.prototype = {
209209
// a primitive, we'll continue to watch for value changes.
210210
_getInitialValue: function() {
211211
var self = this;
212-
self._fRef.on("value", function(snapshot) {
212+
var gotInitialValue = function(snapshot) {
213213
var value = snapshot.val();
214214

215215
switch (typeof value) {
@@ -222,15 +222,17 @@ AngularFire.prototype = {
222222
// For arrays and objects, switch to child methods.
223223
case "object":
224224
self._getChildValues();
225-
self._fRef.off("value");
225+
self._fRef.off("value", gotInitialValue);
226226
break;
227227
default:
228228
throw new Error("Unexpected type from remote data " + typeof value);
229229
}
230230

231231
// Call handlers for the "loaded" event.
232232
self._broadcastEvent("loaded", value);
233-
});
233+
};
234+
235+
self._fRef.on("value", gotInitialValue);
234236
},
235237

236238
// This function attaches child events for object and array types.

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.

0 commit comments

Comments
 (0)