Closed koba04 closed 7 years ago
ReactNoop.flushDeferredPri(7);
ReactNoop.dumpTree();
HOST INSTANCES:
- [root#0]
FIBERS:
- [root] [4*]
IN PROGRESS: 4
- Foo [4*]
ReactNoop.flushDeferredPri(12);
ReactNoop.dumpTree();
HOST INSTANCES:
- [root#0]
FIBERS:
- [root] [4*]
IN PROGRESS: 4
- Foo [4*]
- Bar [4*]
- Bar [4*]
ReactNoop.flushDeferredPri(17);
ReactNoop.dumpTree();
HOST INSTANCES:
- [root#0]
FIBERS:
- [root] [4*]
IN PROGRESS: 4
- Foo [4*]
- Bar [4*]
- div [4*]
- Bar [4*]
ReactNoop.flushDeferredPri(22);
ReactNoop.dumpTree();
HOST INSTANCES:
- [root#0]
FIBERS:
- [root] [4*]
IN PROGRESS: 4
- Foo [4*]
- Bar [4*]
- div [4*]
- p [4*]
- Bar [4*]
ReactNoop.flushDeferredPri(27);
ReactNoop.dumpTree();
HOST INSTANCES:
- [root#0]
FIBERS:
- [root] [4*]
IN PROGRESS: 4
- Foo [4*]
- Bar [0]
- div [0]
- p [0]
- Bar [4*]
ReactNoop.flushDeferredPri(32);
ReactNoop.dumpTree();
HOST INSTANCES:
- [root#0]
FIBERS:
- [root] [4*]
IN PROGRESS: 4
- Foo [4*]
- Bar [0]
- div [0]
- p [0]
- Bar [4*]
- div [4*]
ReactNoop.flushDeferredPri(37);
ReactNoop.dumpTree();
HOST INSTANCES:
- [root#0]
FIBERS:
- [root] [4*]
IN PROGRESS: 4
- Foo [4*]
- Bar [0]
- div [0]
- p [0]
- Bar [4*]
- div [4*]
- p [4*]
ReactNoop.flushDeferredPri(42);
ReactNoop.dumpTree();
HOST INSTANCES:
- [root#0]
- div#1
- p#0
- div#3
- p#2
FIBERS:
- [root] [0]
- Foo [0]
- Bar [0]
- div [0]
- p [0]
- Bar [0]
- div [0]
- p [0]
ReactNoop.flushDeferredPri
is
flushDeferredPri(timeout : number = Infinity) {
var cb = scheduledDeferredCallback;
if (cb === null) {
return;
}
scheduledDeferredCallback = null;
var timeRemaining = timeout;
cb({
timeRemaining() {
// Simulate a fix amount of time progressing between each call.
timeRemaining -= 5;
if (timeRemaining < 0) {
timeRemaining = 0;
}
return timeRemaining;
},
});
},
timeRemaining
is simulating requestIdleCallback
. if timeRemaining
returns 2 and over, ReactFiber processes the next unit of work (Fiber), if not, ReactFiber processes it as a deferred work.