Skip to content

Commit

Permalink
Move immediates to React batchedUpdates
Browse files Browse the repository at this point in the history
Reviewed By: @jspahrsummers

Differential Revision: D2484935
  • Loading branch information
tadeuzagallo authored and facebook-github-bot-4 committed Sep 29, 2015
1 parent ca007aa commit 4c74f01
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions Libraries/Utilities/MessageQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,19 @@ class MessageQueue {
'__callFunction' : '__invokeCallback';
guard(() => this[method].apply(this, call.args));
});
BridgeProfiling.profile('ReactUpdates.batchedUpdates()');

this.__callImmediates();
});
BridgeProfiling.profileEnd();

// batchedUpdates might still trigger setImmediates
while (JSTimersExecution.immediates.length) {
ReactUpdates.batchedUpdates(() => {
this.__callImmediates();
});
}
});
return this.flushedQueue();

return this.__flushedQueue();
}

callFunctionReturnFlushedQueue(module, method, args) {
Expand All @@ -101,17 +109,25 @@ class MessageQueue {
}

flushedQueue() {
this.__callImmediates();
return this.__flushedQueue();
}

/**
* "Private" methods
*/

__callImmediates() {
BridgeProfiling.profile('JSTimersExecution.callImmediates()');
guard(() => JSTimersExecution.callImmediates());
BridgeProfiling.profileEnd();
}

__flushedQueue() {
let queue = this._queue;
this._queue = [[],[],[]];
return queue[0].length ? queue : null;
}

/**
* "Private" methods
*/
__nativeCall(module, method, params, onFail, onSucc) {
if (onFail || onSucc) {
// eventually delete old debug info
Expand Down

0 comments on commit 4c74f01

Please sign in to comment.