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

Commit 6ed1fc1

Browse files
committed
Merge pull request #464 from jamestalmage/simplify-checkMetaVars
Simplify checkMetaVars $watch statement.
2 parents 19c35d0 + eb7cb11 commit 6ed1fc1

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

src/FirebaseObject.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
angular.module('firebase').factory('$FirebaseObject', [
2727
'$parse', '$firebaseUtils', '$log', '$interval',
28-
function($parse, $firebaseUtils, $log, $interval) {
28+
function($parse, $firebaseUtils, $log) {
2929
/**
3030
* This constructor should probably never be called manually. It is used internally by
3131
* <code>$firebase.$asObject()</code>.
@@ -360,29 +360,7 @@
360360
}
361361
}
362362

363-
// Okay, so this magic hack is um... magic. It increments a
364-
// variable every 50 seconds (counterKey) so that whenever $digest
365-
// is run, the variable will be dirty. This allows us to determine
366-
// when $digest is invoked, manually check the meta vars, and
367-
// manually invoke our watcher if the $ prefixed data has changed
368-
(function() {
369-
// create a counter and store it in scope
370-
var counterKey = '_firebaseCounterForVar'+varName;
371-
scope[counterKey] = 0;
372-
// update the counter every 51ms
373-
// why 51? because it must be greater than scopeUpdated's debounce
374-
// or protractor has a conniption
375-
var to = $interval(function() {
376-
scope[counterKey]++;
377-
}, 51, 0, false);
378-
// watch the counter for changes (which means $digest ran)
379-
self.subs.push(scope.$watch(counterKey, checkMetaVars));
380-
// cancel our interval and clear var from scope if unbound
381-
self.subs.push(function() {
382-
$interval.cancel(to);
383-
delete scope[counterKey];
384-
});
385-
})();
363+
self.subs.push(scope.$watch(checkMetaVars));
386364

387365
setScope(rec);
388366
self.subs.push(scope.$on('$destroy', self.unbind.bind(self)));

0 commit comments

Comments
 (0)