mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Changelog: [Internal] This diff replaced all the internal occurrences of "Immediate" with "ReactNativeMicrotask" in the legacy bridge and then polyfilled the original immediate APIs during the timer setup phases as aliases of them. Note that this diff is part of a larger refactoring. Reviewed By: RSNara Differential Revision: D29785430 fbshipit-source-id: 7325d2a7358a6c9baa3e9abb8acf90414de5072f
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict-local
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
// In bridgeless mode, timers are host functions installed from cpp.
|
|
if (!global.RN$Bridgeless) {
|
|
const {polyfillGlobal} = require('../Utilities/PolyfillFunctions');
|
|
|
|
/**
|
|
* Set up timers.
|
|
* You can use this module directly, or just require InitializeCore.
|
|
*/
|
|
const defineLazyTimer = name => {
|
|
polyfillGlobal(name, () => require('./Timers/JSTimers')[name]);
|
|
};
|
|
defineLazyTimer('setTimeout');
|
|
defineLazyTimer('clearTimeout');
|
|
defineLazyTimer('setInterval');
|
|
defineLazyTimer('clearInterval');
|
|
defineLazyTimer('requestAnimationFrame');
|
|
defineLazyTimer('cancelAnimationFrame');
|
|
defineLazyTimer('requestIdleCallback');
|
|
defineLazyTimer('cancelIdleCallback');
|
|
|
|
/**
|
|
* Set up immediate APIs as aliases to the ReactNativeMicrotask APIs.
|
|
*/
|
|
polyfillGlobal(
|
|
'setImmediate',
|
|
() => require('./Timers/JSTimers').queueReactNativeMicrotask,
|
|
);
|
|
polyfillGlobal(
|
|
'clearImmediate',
|
|
() => require('./Timers/JSTimers').clearReactNativeMicrotask,
|
|
);
|
|
}
|