-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsample.prg
More file actions
63 lines (55 loc) · 1.54 KB
/
sample.prg
File metadata and controls
63 lines (55 loc) · 1.54 KB
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
58
59
60
61
62
63
SET PROCEDURE TO promises.prg
CLEAR
WITH Promise("MyPromiseExecutorInterval")
WITH .then("MyPromiseThen")
WITH .then("MyPromiseThen")
.then("MyPromiseThen")
ENDWITH
ENDWITH
.then("MyPromiseThen")
ENDWITH
WITH Promise("MyPromiseExecutorTimeout")
.then("MyPromiseThen")
ENDWITH
DEFINE CLASS MyPromiseExecutorInterval as Callable
FUNCTION call(resolve as Callable, reject as Callable)
WITH CREATEOBJECT("MyInterval")
.SetInterval(10, m.resolve, 15, "Hello, Interval!")
ENDWITH
ENDFUNC
ENDDEFINE
DEFINE CLASS MyPromiseExecutorTimeout as Callable
FUNCTION call(resolve as Callable, reject as Callable)
WITH CREATEOBJECT("MyTimeout")
.SetTimeout(100, m.resolve, "Hello, Timeout!")
ENDWITH
ENDFUNC
ENDDEFINE
DEFINE CLASS MyPromiseThen as Callable
FUNCTION call(value)
LOCAL res
m.res = TRANSFORM(m.value) + " then " + SYS(2015)
? m.res
RETURN m.res
ENDFUNC
ENDDEFINE
DEFINE CLASS MyInterval as IntervalCallable
cnt = 0
FUNCTION call(resolve as Callable, cntMax as Integer, msg as String)
This.cnt = This.cnt + 1
? this.cnt
IF This.cnt = m.cntMax
m.resolve.call(m.msg)
This.ClearInterval()
ENDIF
ENDFUNC
ENDDEFINE
DEFINE CLASS MyTimeout as TimeoutCallable
cnt = 0
FUNCTION call(resolve as Callable, msg as String)
This.cnt = This.cnt + 1
? this.cnt
m.resolve.call(m.msg)
This.ClearTimeout()
ENDFUNC
ENDDEFINE