Files
react-native/Libraries/Core/setUpTimers.js
T
Emily Janzer 533932ada9 Don't set up JS timers in bridgeless RN
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
2019-06-12 16:18:36 -07:00

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');
}