mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
RN: Avoid Rejections in InteractionManagerStub (#49241)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/49241 In auditing differences between `InteractionManager` and `InteractionManagerStub` (used to evaluate to entirely remove the former all together), I noticed a behavioral disparity with how errors are handled. In `InteractionManager`, the promise that's returned is never rejected, whereas `InteractionManagerStub` propagates errors by rejecting the promise that's returned. This changes `InteractionManagerStub` to behave like `InteractionManager` for the purpose of comparing apples-to-apples. Changelog: [Internal] Reviewed By: javache Differential Revision: D69275495 fbshipit-source-id: 05439a0cadc1f76b34a3f1457f7db31d6bda2a90
This commit is contained in:
committed by
Facebook GitHub Bot
parent
57c291bbc4
commit
5635d5c0a3
@@ -25,6 +25,14 @@ type Task =
|
||||
}
|
||||
| (() => void);
|
||||
|
||||
// NOTE: The original implementation of `InteractionManager` never rejected
|
||||
// the returned promise. This preserves that behavior in the stub.
|
||||
function reject(error: Error): void {
|
||||
setTimeout(() => {
|
||||
throw error;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* InteractionManager allows long-running work to be scheduled after any
|
||||
* interactions/animations have completed. In particular, this allows JavaScript
|
||||
@@ -97,7 +105,7 @@ const InteractionManagerStub = {
|
||||
...
|
||||
} {
|
||||
let immediateID: ?$FlowIssue;
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
const promise = new Promise(resolve => {
|
||||
immediateID = setImmediate(() => {
|
||||
if (typeof task === 'object' && task !== null) {
|
||||
if (typeof task.gen === 'function') {
|
||||
|
||||
Reference in New Issue
Block a user