Skip to content

Commit d62fa75

Browse files
committed
fixed error in throttling function
1 parent 17b74f5 commit d62fa75

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/backend/helpers.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ export const throttle = (f, t) => {
1717
if (isOnCooldown && isCallQueued) return;
1818
if (isOnCooldown) {
1919
isCallQueued = true;
20+
console.log('snapshot update already queued');
2021
return;
2122
}
23+
console.log('no queue, updating snapshot from trigger func');
2224
f();
2325
isOnCooldown = true;
2426
isCallQueued = false;
@@ -27,11 +29,14 @@ export const throttle = (f, t) => {
2729
if (isCallQueued) {
2830
isCallQueued = false;
2931
isOnCooldown = true; // not needed I think
32+
console.log('calling queued call');
33+
f();
3034
setTimeout(runAfterTimeout, t);
3135
return;
3236
}
3337
isOnCooldown = false;
3438
};
39+
console.log('queueing snapshot update');
3540
setTimeout(runAfterTimeout, t);
3641
};
3742
return throttledFunc;

src/backend/linkFiber.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export default (snap: Snapshot, mode: Mode): ()=>void => {
171171
elementType ? elementType.name : 'nameless',
172172
componentData);
173173
}
174+
if (newState !== 'stateless') console.log('state updated:', newState);
174175
} else {
175176
newNode = tree;
176177
}
@@ -228,7 +229,12 @@ export default (snap: Snapshot, mode: Mode): ()=>void => {
228229
devTools.onCommitFiberRoot = (function (original) {
229230
return function (...args) {
230231
fiberRoot = args[1];
231-
if (doWork) throttledUpdateSnapshot();
232+
console.log('in CFR committed fiber');
233+
if (doWork) {
234+
console.log('in CFR: updating snapshot');
235+
throttledUpdateSnapshot();
236+
}
237+
console.log('in CFR updated snapshot');
232238
return original(...args);
233239
};
234240
}(devTools.onCommitFiberRoot));

0 commit comments

Comments
 (0)