mirror of
https://github.com/status-im/react-native.git
synced 2025-01-14 11:34:23 +00:00
A little more debugging code for Incremental
Reviewed By: astreet Differential Revision: D3091688 fb-gh-sync-id: 4f91d5126a16b56904fa4af7acdc32b9bb873c6d shipit-source-id: 4f91d5126a16b56904fa4af7acdc32b9bb873c6d
This commit is contained in:
parent
18badf1c3e
commit
ca353d0829
@ -129,6 +129,7 @@ class Incremental extends React.Component {
|
||||
this.setState({doIncrementalRender: true}, resolve);
|
||||
}),
|
||||
}).then(() => {
|
||||
DEBUG && console.log('call onDone for ' + this.getName());
|
||||
this._mounted && this.props.onDone && this.props.onDone();
|
||||
});
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ import type {Task} from 'TaskQueue';
|
||||
|
||||
const _emitter = new EventEmitter();
|
||||
|
||||
const DEBUG_DELAY = 0;
|
||||
|
||||
/**
|
||||
* InteractionManager allows long-running work to be scheduled after any
|
||||
* interactions/animations have completed. In particular, this allows JavaScript
|
||||
@ -143,7 +145,7 @@ let _deadline = -1;
|
||||
function _scheduleUpdate() {
|
||||
if (!_nextUpdateHandle) {
|
||||
if (_deadline > 0) {
|
||||
_nextUpdateHandle = setTimeout(_processUpdate, 0);
|
||||
_nextUpdateHandle = setTimeout(_processUpdate, 0 + DEBUG_DELAY);
|
||||
} else {
|
||||
_nextUpdateHandle = setImmediate(_processUpdate);
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ type PromiseTask = {
|
||||
};
|
||||
export type Task = Function | SimpleTask | PromiseTask;
|
||||
|
||||
const DEBUG = false;
|
||||
|
||||
/**
|
||||
* TaskQueue - A system for queueing and executing a mix of simple callbacks and
|
||||
* trees of dependent tasks based on Promises. No tasks are executed unless
|
||||
@ -81,13 +83,15 @@ class TaskQueue {
|
||||
* Executes the next task in the queue.
|
||||
*/
|
||||
processNext(): void {
|
||||
let queue = this._getCurrentQueue();
|
||||
const queue = this._getCurrentQueue();
|
||||
if (queue.length) {
|
||||
const task = queue.shift();
|
||||
try {
|
||||
if (task.gen) {
|
||||
DEBUG && console.log('genPromise for task ' + task.name);
|
||||
this._genPromise((task: any)); // Rather than annoying tagged union
|
||||
} else if (task.run) {
|
||||
DEBUG && console.log('run task ' + task.name);
|
||||
task.run();
|
||||
} else {
|
||||
invariant(
|
||||
@ -95,6 +99,7 @@ class TaskQueue {
|
||||
'Expected Function, SimpleTask, or PromiseTask, but got: ' +
|
||||
JSON.stringify(task)
|
||||
);
|
||||
DEBUG && console.log('run anonymous task');
|
||||
task();
|
||||
}
|
||||
} catch (e) {
|
||||
@ -115,6 +120,7 @@ class TaskQueue {
|
||||
queue.tasks.length === 0 &&
|
||||
this._queueStack.length > 1) {
|
||||
this._queueStack.pop();
|
||||
DEBUG && console.log('popped queue: ', {stackIdx, queueStackSize: this._queueStack.length});
|
||||
return this._getCurrentQueue();
|
||||
} else {
|
||||
return queue.tasks;
|
||||
@ -128,8 +134,11 @@ class TaskQueue {
|
||||
// happens once it is fully processed.
|
||||
this._queueStack.push({tasks: [], popable: false});
|
||||
const stackIdx = this._queueStack.length - 1;
|
||||
DEBUG && console.log('push new queue: ', {stackIdx});
|
||||
DEBUG && console.log('exec gen task ' + task.name);
|
||||
ErrorUtils.applyWithGuard(task.gen)
|
||||
.then(() => {
|
||||
DEBUG && console.log('onThen for gen task ' + task.name, {stackIdx, queueStackSize: this._queueStack.length});
|
||||
this._queueStack[stackIdx].popable = true;
|
||||
this.hasTasksToProcess() && this._onMoreTasks();
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user