Fix: setInterval callback is not fired while touch events are being processed

Resolves #2116
This commit is contained in:
Rossen Hristov
2017-01-03 10:49:04 +02:00
parent ed0969d96d
commit 9d2a98f558

View File

@ -1,4 +1,6 @@
//iOS specific timer functions implementation.
import * as utils from "utils/utils";
//iOS specific timer functions implementation.
var timeoutCallbacks = new Map<number, KeyValuePair<NSTimer, TimerTargetImpl>>();
var timerId = 0;
@ -52,6 +54,9 @@ function createTimerAndGetId(callback: Function, milliseconds: number, shouldRep
let timerTarget = TimerTargetImpl.initWithCallback(callback, id, shouldRepeat);
let timer = NSTimer.scheduledTimerWithTimeIntervalTargetSelectorUserInfoRepeats(milliseconds / 1000, timerTarget, "tick", null, shouldRepeat);
// https://github.com/NativeScript/NativeScript/issues/2116
utils.ios.getter(NSRunLoop, NSRunLoop.currentRunLoop).addTimerForMode(timer, NSRunLoopCommonModes);
let pair: KeyValuePair<NSTimer, TimerTargetImpl> = { k: timer, v: timerTarget };
timeoutCallbacks.set(id, pair);