[ReactNative] Flush ReactUpdates only once per batch
This commit is contained in:
parent
ffb3026419
commit
2bda21fbf0
|
@ -10,7 +10,9 @@
|
|||
* @flow
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ErrorUtils = require('ErrorUtils');
|
||||
var ReactUpdates = require('ReactUpdates');
|
||||
|
||||
var invariant = require('invariant');
|
||||
var warning = require('warning');
|
||||
|
@ -307,21 +309,23 @@ var MessageQueueMixin = {
|
|||
);
|
||||
},
|
||||
|
||||
processBatch: function (batch) {
|
||||
processBatch: function(batch) {
|
||||
var self = this;
|
||||
batch.forEach(function (call) {
|
||||
invariant(
|
||||
call.module === 'BatchedBridge',
|
||||
'All the calls should pass through the BatchedBridge module'
|
||||
);
|
||||
if (call.method === 'callFunctionReturnFlushedQueue') {
|
||||
self.callFunction.apply(self, call.args);
|
||||
} else if (call.method === 'invokeCallbackAndReturnFlushedQueue') {
|
||||
self.invokeCallback.apply(self, call.args);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Unrecognized method called on BatchedBridge: ' + call.method);
|
||||
}
|
||||
ReactUpdates.batchedUpdates(function() {
|
||||
batch.forEach(function(call) {
|
||||
invariant(
|
||||
call.module === 'BatchedBridge',
|
||||
'All the calls should pass through the BatchedBridge module'
|
||||
);
|
||||
if (call.method === 'callFunctionReturnFlushedQueue') {
|
||||
self.callFunction.apply(self, call.args);
|
||||
} else if (call.method === 'invokeCallbackAndReturnFlushedQueue') {
|
||||
self.invokeCallback.apply(self, call.args);
|
||||
} else {
|
||||
throw new Error(
|
||||
'Unrecognized method called on BatchedBridge: ' + call.method);
|
||||
}
|
||||
});
|
||||
});
|
||||
return this.flushedQueue();
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue