From c0efa1670a03fa432b910a948c17eafcaf9484a3 Mon Sep 17 00:00:00 2001 From: Spencer Ahrens Date: Tue, 23 Apr 2019 16:00:44 -0700 Subject: [PATCH] cleanup InteractionManager debugging a little Summary: adding the flow types makes it impossible to forget to change them back. Reviewed By: yungsters Differential Revision: D14990037 fbshipit-source-id: d018e4cf6798d50bcfb44b55d3c68ca7f5beef72 --- Libraries/Interaction/InteractionManager.js | 10 +++++----- Libraries/Interaction/TaskQueue.js | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Libraries/Interaction/InteractionManager.js b/Libraries/Interaction/InteractionManager.js index b1dc52813744cf..22225198fccd3c 100644 --- a/Libraries/Interaction/InteractionManager.js +++ b/Libraries/Interaction/InteractionManager.js @@ -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 @@ -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); @@ -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); diff --git a/Libraries/Interaction/TaskQueue.js b/Libraries/Interaction/TaskQueue.js index cc019b57036b8c..db9ce173058853 100644 --- a/Libraries/Interaction/TaskQueue.js +++ b/Libraries/Interaction/TaskQueue.js @@ -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 @@ -100,10 +100,10 @@ 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( @@ -111,7 +111,7 @@ class TaskQueue { '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) { @@ -135,7 +135,7 @@ class TaskQueue { ) { this._queueStack.pop(); DEBUG && - infoLog('popped queue: ', { + infoLog('TaskQueue: popped queue: ', { stackIdx, queueStackSize: this._queueStack.length, }); @@ -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, });