[ReactNative] Refactor BatchedBridge and MessageQueue
Summary:
@public
The current implementation of `MessageQueue` is huge, over-complicated and spread
across `MethodQueue`, `MethodQueueMixin`, `BatchedBridge` and `BatchedBridgeFactory`
Refactored in a simpler way, were it's just a `MessageQueue` class and `BatchedBridge`
is only an instance of it.
Test Plan:
I had to make some updates to the tests, but no real update to the native side.
There's also tests covering the `remoteAsync` methods, and more integration tests for UIExplorer.
Verified whats being used by Android, and it should be safe, also tests Android tests have been pretty reliable.
Manually testing: Create a big hierarchy, like `<ListView>` example. Use the `TimerMixin` example to generate multiple calls.
Test the failure callback on the `Geolocation` example.
All the calls go through this entry point, so it's hard to miss if it's broken.
2015-06-17 14:51:48 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*
|
|
|
|
* @providesModule BatchedBridge
|
2016-09-23 18:12:54 +00:00
|
|
|
* @flow
|
[ReactNative] Refactor BatchedBridge and MessageQueue
Summary:
@public
The current implementation of `MessageQueue` is huge, over-complicated and spread
across `MethodQueue`, `MethodQueueMixin`, `BatchedBridge` and `BatchedBridgeFactory`
Refactored in a simpler way, were it's just a `MessageQueue` class and `BatchedBridge`
is only an instance of it.
Test Plan:
I had to make some updates to the tests, but no real update to the native side.
There's also tests covering the `remoteAsync` methods, and more integration tests for UIExplorer.
Verified whats being used by Android, and it should be safe, also tests Android tests have been pretty reliable.
Manually testing: Create a big hierarchy, like `<ListView>` example. Use the `TimerMixin` example to generate multiple calls.
Test the failure callback on the `Geolocation` example.
All the calls go through this entry point, so it's hard to miss if it's broken.
2015-06-17 14:51:48 +00:00
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2015-12-08 23:57:34 +00:00
|
|
|
const MessageQueue = require('MessageQueue');
|
2016-09-23 18:12:54 +00:00
|
|
|
const BatchedBridge = new MessageQueue();
|
[ReactNative] Refactor BatchedBridge and MessageQueue
Summary:
@public
The current implementation of `MessageQueue` is huge, over-complicated and spread
across `MethodQueue`, `MethodQueueMixin`, `BatchedBridge` and `BatchedBridgeFactory`
Refactored in a simpler way, were it's just a `MessageQueue` class and `BatchedBridge`
is only an instance of it.
Test Plan:
I had to make some updates to the tests, but no real update to the native side.
There's also tests covering the `remoteAsync` methods, and more integration tests for UIExplorer.
Verified whats being used by Android, and it should be safe, also tests Android tests have been pretty reliable.
Manually testing: Create a big hierarchy, like `<ListView>` example. Use the `TimerMixin` example to generate multiple calls.
Test the failure callback on the `Geolocation` example.
All the calls go through this entry point, so it's hard to miss if it's broken.
2015-06-17 14:51:48 +00:00
|
|
|
|
2015-12-08 23:57:34 +00:00
|
|
|
// TODO: Move these around to solve the cycle in a cleaner way.
|
2016-09-23 18:12:54 +00:00
|
|
|
BatchedBridge.registerCallableModule('Systrace', require('Systrace'));
|
|
|
|
BatchedBridge.registerCallableModule('JSTimersExecution', require('JSTimersExecution'));
|
2016-04-29 14:34:51 +00:00
|
|
|
BatchedBridge.registerCallableModule('HeapCapture', require('HeapCapture'));
|
2016-08-02 18:10:48 +00:00
|
|
|
BatchedBridge.registerCallableModule('SamplingProfiler', require('SamplingProfiler'));
|
2015-12-08 23:57:34 +00:00
|
|
|
|
2015-12-29 00:43:08 +00:00
|
|
|
if (__DEV__) {
|
2015-12-29 00:43:21 +00:00
|
|
|
BatchedBridge.registerCallableModule('HMRClient', require('HMRClient'));
|
2015-12-29 00:43:08 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 23:57:34 +00:00
|
|
|
// Wire up the batched bridge on the global object so that we can call into it.
|
|
|
|
// Ideally, this would be the inverse relationship. I.e. the native environment
|
|
|
|
// provides this global directly with its script embedded. Then this module
|
|
|
|
// would export it. A possible fix would be to trim the dependencies in
|
|
|
|
// MessageQueue to its minimal features and embed that in the native runtime.
|
|
|
|
|
2016-06-30 08:57:30 +00:00
|
|
|
Object.defineProperty(global, '__fbBatchedBridge', {
|
|
|
|
configurable: true,
|
|
|
|
value: BatchedBridge,
|
|
|
|
});
|
2015-12-08 23:57:34 +00:00
|
|
|
|
[ReactNative] Refactor BatchedBridge and MessageQueue
Summary:
@public
The current implementation of `MessageQueue` is huge, over-complicated and spread
across `MethodQueue`, `MethodQueueMixin`, `BatchedBridge` and `BatchedBridgeFactory`
Refactored in a simpler way, were it's just a `MessageQueue` class and `BatchedBridge`
is only an instance of it.
Test Plan:
I had to make some updates to the tests, but no real update to the native side.
There's also tests covering the `remoteAsync` methods, and more integration tests for UIExplorer.
Verified whats being used by Android, and it should be safe, also tests Android tests have been pretty reliable.
Manually testing: Create a big hierarchy, like `<ListView>` example. Use the `TimerMixin` example to generate multiple calls.
Test the failure callback on the `Geolocation` example.
All the calls go through this entry point, so it's hard to miss if it's broken.
2015-06-17 14:51:48 +00:00
|
|
|
module.exports = BatchedBridge;
|