Skip to content

Commit

Permalink
cleanup InteractionManager debugging a little
Browse files Browse the repository at this point in the history
Summary: adding the flow types makes it impossible to forget to change them back.

Reviewed By: yungsters

Differential Revision: D14990037

fbshipit-source-id: d018e4cf6798d50bcfb44b55d3c68ca7f5beef72
  • Loading branch information
sahrens authored and facebook-github-bot committed Apr 23, 2019
1 parent 11439ea commit c0efa16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions Libraries/Interaction/InteractionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import type {Task} from 'TaskQueue';

const _emitter = new EventEmitter();

const DEBUG_DELAY = 0;
const DEBUG = false;
const DEBUG_DELAY: 0 = 0;
const DEBUG: false = false;

/**
* InteractionManager allows long-running work to be scheduled after any
Expand Down Expand Up @@ -121,7 +121,7 @@ const InteractionManager = {
* Notify manager that an interaction has started.
*/
createInteractionHandle(): Handle {
DEBUG && infoLog('create interaction handle');
DEBUG && infoLog('InteractionManager: create interaction handle');
_scheduleUpdate();
const handle = ++_inc;
_addInteractionSet.add(handle);
Expand All @@ -132,8 +132,8 @@ const InteractionManager = {
* Notify manager that an interaction has completed.
*/
clearInteractionHandle(handle: Handle) {
DEBUG && infoLog('clear interaction handle');
invariant(!!handle, 'Must provide a handle to clear.');
DEBUG && infoLog('InteractionManager: clear interaction handle');
invariant(!!handle, 'InteractionManager: Must provide a handle to clear.');
_scheduleUpdate();
_addInteractionSet.delete(handle);
_deleteInteractionSet.add(handle);
Expand Down
16 changes: 8 additions & 8 deletions Libraries/Interaction/TaskQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type PromiseTask = {
};
export type Task = Function | SimpleTask | PromiseTask;

const DEBUG = false;
const DEBUG: false = false;

/**
* TaskQueue - A system for queueing and executing a mix of simple callbacks and
Expand Down Expand Up @@ -100,18 +100,18 @@ class TaskQueue {
const task = queue.shift();
try {
if (task.gen) {
DEBUG && infoLog('genPromise for task ' + task.name);
DEBUG && infoLog('TaskQueue: genPromise for task ' + task.name);
this._genPromise((task: any)); // Rather than annoying tagged union
} else if (task.run) {
DEBUG && infoLog('run task ' + task.name);
DEBUG && infoLog('TaskQueue: run task ' + task.name);
task.run();
} else {
invariant(
typeof task === 'function',
'Expected Function, SimpleTask, or PromiseTask, but got:\n' +
JSON.stringify(task, null, 2),
);
DEBUG && infoLog('run anonymous task');
DEBUG && infoLog('TaskQueue: run anonymous task');
task();
}
} catch (e) {
Expand All @@ -135,7 +135,7 @@ class TaskQueue {
) {
this._queueStack.pop();
DEBUG &&
infoLog('popped queue: ', {
infoLog('TaskQueue: popped queue: ', {
stackIdx,
queueStackSize: this._queueStack.length,
});
Expand All @@ -152,13 +152,13 @@ class TaskQueue {
// happens once it is fully processed.
this._queueStack.push({tasks: [], popable: false});
const stackIdx = this._queueStack.length - 1;
DEBUG && infoLog('push new queue: ', {stackIdx});
DEBUG && infoLog('exec gen task ' + task.name);
DEBUG && infoLog('TaskQueue: push new queue: ', {stackIdx});
DEBUG && infoLog('TaskQueue: exec gen task ' + task.name);
task
.gen()
.then(() => {
DEBUG &&
infoLog('onThen for gen task ' + task.name, {
infoLog('TaskQueue: onThen for gen task ' + task.name, {
stackIdx,
queueStackSize: this._queueStack.length,
});
Expand Down

0 comments on commit c0efa16

Please sign in to comment.