[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');
|
2017-12-11 15:59:45 +00:00
|
|
|
|
|
|
|
// MessageQueue can install a global handler to catch all exceptions where JS users can register their own behavior
|
|
|
|
// This handler makes all exceptions to be handled inside MessageQueue rather than by the VM at its origin
|
|
|
|
// This makes stacktraces to be placed at MessageQueue rather than at where they were launched
|
|
|
|
// The parameter __fbUninstallRNGlobalErrorHandler is passed to MessageQueue to prevent the handler from being installed
|
|
|
|
//
|
2018-01-13 06:03:51 +00:00
|
|
|
// __fbUninstallRNGlobalErrorHandler is conditionally set by the Inspector while the VM is paused for initialization
|
2017-12-11 15:59:45 +00:00
|
|
|
// If the Inspector isn't present it defaults to undefined and the global error handler is installed
|
|
|
|
// The Inspector can still call MessageQueue#uninstallGlobalErrorHandler to uninstalled on attach
|
|
|
|
|
|
|
|
const BatchedBridge = new MessageQueue(
|
|
|
|
// $FlowFixMe
|
|
|
|
typeof __fbUninstallRNGlobalErrorHandler !== 'undefined' &&
|
|
|
|
__fbUninstallRNGlobalErrorHandler === true, // eslint-disable-line no-undef
|
|
|
|
);
|
[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
|
|
|
// 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;
|