From 9d2a98f558e6405e3a60c99293cc4295503810ca Mon Sep 17 00:00:00 2001 From: Rossen Hristov Date: Tue, 3 Jan 2017 10:49:04 +0200 Subject: [PATCH] Fix: setInterval callback is not fired while touch events are being processed Resolves #2116 --- tns-core-modules/timer/timer.ios.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tns-core-modules/timer/timer.ios.ts b/tns-core-modules/timer/timer.ios.ts index 953e6de31..33c12cd92 100644 --- a/tns-core-modules/timer/timer.ios.ts +++ b/tns-core-modules/timer/timer.ios.ts @@ -1,4 +1,6 @@ -//iOS specific timer functions implementation. +import * as utils from "utils/utils"; + +//iOS specific timer functions implementation. var timeoutCallbacks = new Map>(); 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 = { k: timer, v: timerTarget }; timeoutCallbacks.set(id, pair);