FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
NativeScript/timer/timer.ios.ts at patch-1 · rclai/NativeScript · GitHub
rclai
/
NativeScript
Public
forked from
NativeScript/NativeScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
NativeScript
/
timer
/
timer.ios.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
57 lines (44 loc) · 1.49 KB
Breadcrumbs
NativeScript
/
timer
/
timer.ios.ts
Copy path
File metadata and controls
57 lines (44 loc) · 1.49 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* iOS specific timer functions implementation.
*/
var
timeoutCallbacks
=
{
}
;
var
timerId
=
0
;
class
TimerTargetImpl
extends
NSObject
{
static
new
(
)
:
TimerTargetImpl
{
return
<
TimerTargetImpl
>
super
.
new
(
)
;
}
private
_callback
:
Function
;
public
initWithCallback
(
callback
:
Function
)
:
TimerTargetImpl
{
this
.
_callback
=
callback
;
return
this
;
}
public
tick
(
timer
)
:
void
{
this
.
_callback
(
)
;
}
public
static
ObjCExposedMethods
=
{
"tick"
:
{
returns
:
interop
.
types
.
void
,
params
:
[
NSTimer
]
}
}
;
}
function
createTimerAndGetId
(
callback
:
Function
,
milliseconds
:
number
,
shouldRepeat
:
boolean
)
:
number
{
timerId
++
;
var
id
=
timerId
;
var
timerTarget
=
TimerTargetImpl
.
new
(
)
.
initWithCallback
(
callback
)
;
var
timer
=
NSTimer
.
scheduledTimerWithTimeIntervalTargetSelectorUserInfoRepeats
(
milliseconds
/
1000
,
timerTarget
,
"tick"
,
null
,
shouldRepeat
)
;
if
(
!
timeoutCallbacks
[
id
]
)
{
timeoutCallbacks
[
id
]
=
timer
;
}
return
id
;
}
export
function
setTimeout
(
callback
:
Function
,
milliseconds
=
0
)
:
number
{
return
createTimerAndGetId
(
callback
,
milliseconds
,
false
)
;
}
export
function
clearTimeout
(
id
:
number
)
:
void
{
if
(
timeoutCallbacks
[
id
]
)
{
timeoutCallbacks
[
id
]
.
invalidate
(
)
;
delete
timeoutCallbacks
[
id
]
;
}
}
export
function
setInterval
(
callback
:
Function
,
milliseconds
=
0
)
:
number
{
return
createTimerAndGetId
(
callback
,
milliseconds
,
true
)
;
}
export
var
clearInterval
=
clearTimeout
;
Back
|
FazBrowse Home
|
New Git URL