MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / createTimerAndGetId

Function createTimerAndGetId

packages/core/timer/index.ios.ts:51–70  ·  view source on GitHub ↗
(callback: Function, milliseconds: number, shouldRepeat: boolean)

Source from the content-addressed store, hash-verified

49}
50
51function createTimerAndGetId(callback: Function, milliseconds: number, shouldRepeat: boolean): number {
52 // Cast to Number
53 milliseconds += 0;
54
55 timerId++;
56 const id = timerId;
57 const timerTarget = TimerTargetImpl.initWithCallback(callback, id, shouldRepeat);
58 const timer = NSTimer.scheduledTimerWithTimeIntervalTargetSelectorUserInfoRepeats(milliseconds / 1000, timerTarget, 'tick', null, shouldRepeat);
59
60 // https://github.com/NativeScript/NativeScript/issues/2116
61 NSRunLoop.currentRunLoop.addTimerForMode(timer, NSRunLoopCommonModes);
62
63 const pair: KeyValuePair<NSTimer, TimerTargetImpl> = {
64 k: timer,
65 v: timerTarget,
66 };
67 timeoutCallbacks.set(id, pair);
68
69 return id;
70}
71
72export function setTimeout(callback: Function, milliseconds = 0, ...args): number {
73 const invoke = () => callback(...args);

Callers 2

setTimeoutFunction · 0.85
setIntervalFunction · 0.85

Calls 2

initWithCallbackMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected