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

Commit 49850fe

Browse files
committed
perf: use value passed to debounced function instead of re-getting scope
1 parent cd12922 commit 49850fe

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/FirebaseObject.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -324,23 +324,20 @@
324324
scopeValue.$value === rec.$value;
325325
}
326326

327-
function getScope() {
328-
return $firebaseUtils.scopeData(parsed(scope));
329-
}
330-
331327
function setScope(rec) {
332328
parsed.assign(scope, $firebaseUtils.scopeData(rec));
333329
}
334330

335-
var send = $firebaseUtils.debounce(function() {
336-
rec.$$scopeUpdated(getScope())
331+
var send = $firebaseUtils.debounce(function(val) {
332+
rec.$$scopeUpdated($firebaseUtils.scopeData(val))
337333
['finally'](function() { sending = false; });
338334
}, 50, 500);
339335

340336
var scopeUpdated = function(newVal) {
341-
if( !equals(newVal[0]) ) {
337+
newVal = newVal[0];
338+
if( !equals(newVal) ) {
342339
sending = true;
343-
send();
340+
send(newVal);
344341
}
345342
};
346343

0 commit comments

Comments
 (0)