forked from newspeaklanguage/newspeak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCounterUI.ns
59 lines (59 loc) · 1.12 KB
/
CounterUI.ns
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
Newspeak3
'Root'
class CounterUI usingPlatform: p = (
|
private Subject = p hopscotch Subject.
private Presenter = p hopscotch Presenter.
|
) (
public class Counter = (
| public count <Integer> ::= 0. |
) (
) : (
)
class CounterPresenter onSubject: s <CounterSubject> = Presenter onSubject: s(
) (
definition = (
^row: {
label: subject count.
mediumBlank.
button: 'increment' action: [updateGUI: [subject increment]].
button: 'decrement' action: [updateGUI: [subject decrement]].
button: 'reset' action: [updateGUI: [subject clear]].
}.
)
public isKindOfCounterPresenter = (
^true
)
isMyKind: other = (
^other isKindOfCounterPresenter
)
) : (
)
public class CounterSubject onModel: m <Counter> = Subject onModel: m(
) (
createPresenter ^ <CounterPresenter> = (
^CounterPresenter onSubject: self
)
public isKindOfCounterSubject = (
^true
)
isMyKind: other = (
^other isKindOfCounterSubject
)
public decrement = (
model count: count - 1
)
public increment = (
model count: count + 1
)
public count ^ <Integer> = (
^model count
)
public clear = (
model count: 0
)
) : (
)
) : (
)