mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-09 22:43:10 +08:00
Immediate dispatch 0 time timers
Summary: Calling setTimeout(f, 0) will currently schedule f to be called the next frame instead of immediately (which is how it behaves on iOS). This immediately calls back to JS and invokes the function. Reviewed By: astreet, tadeuzagallo Differential Revision: D3006125 fb-gh-sync-id: 9fa109ed82836a718cbb2e8cb21da4943d96f5f6 shipit-source-id: 9fa109ed82836a718cbb2e8cb21da4943d96f5f6
This commit is contained in:
committed by
Facebook Github Bot 1
parent
8d52567754
commit
ea882b6f16
@@ -217,6 +217,14 @@ public final class Timing extends ReactContextBaseJavaModule implements Lifecycl
|
||||
long adjustedDuration = (long) Math.max(
|
||||
0,
|
||||
jsSchedulingTime - SystemClock.currentTimeMillis() + duration);
|
||||
if (duration == 0 && !repeat) {
|
||||
WritableArray timerToCall = Arguments.createArray();
|
||||
timerToCall.pushInt(callbackID);
|
||||
getReactApplicationContext().getJSModule(executorToken, JSTimersExecution.class)
|
||||
.callTimers(timerToCall);
|
||||
return;
|
||||
}
|
||||
|
||||
long initialTargetTime = SystemClock.nanoTime() / 1000000 + adjustedDuration;
|
||||
Timer timer = new Timer(executorToken, callbackID, initialTargetTime, duration, repeat);
|
||||
synchronized (mTimerGuard) {
|
||||
|
||||
Reference in New Issue
Block a user