mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
533932ada9
Summary: For bridgeless RN we're not going to use the JSTimers module + Timing native module for timers (e.g. setTimeout, setImmediate, etc.). Instead we're going to install global functions from cpp for each of these, so we can just skip setUpTimers entirely in this case. Reviewed By: fkgozali Differential Revision: D15790638 fbshipit-source-id: 1626fe90a27cb8d385cbb700ad932969f708f0cb
34 lines
1003 B
JavaScript
34 lines
1003 B
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('setInterval');
|
|
defineLazyTimer('setImmediate');
|
|
defineLazyTimer('clearTimeout');
|
|
defineLazyTimer('clearInterval');
|
|
defineLazyTimer('clearImmediate');
|
|
defineLazyTimer('requestAnimationFrame');
|
|
defineLazyTimer('cancelAnimationFrame');
|
|
defineLazyTimer('requestIdleCallback');
|
|
defineLazyTimer('cancelIdleCallback');
|
|
}
|