[ReactNative] Create private underlying bridge to prevent retain cycles

This commit is contained in:
Tadeu Zagallo
2015-05-04 10:35:49 -07:00
parent b532ec000f
commit 132a9170f1
12 changed files with 522 additions and 349 deletions

View File

@@ -322,23 +322,24 @@ var MessageQueueMixin = {
processBatch: function(batch) {
var self = this;
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 guardReturn(function () {
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();
}, null, this._flushedQueueUnguarded, this);
},
setLoggingEnabled: function(enabled) {