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

Resolves #2116
This commit is contained in:
Rossen Hristov
2016-12-13 14:33:01 +02:00
parent 624717a396
commit 5338484c4b

View File

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