-
Notifications
You must be signed in to change notification settings - Fork 20
/
main-view-model.ts
43 lines (33 loc) · 955 Bytes
/
main-view-model.ts
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
import {Observable} from 'data/observable';
export class HelloWorldModel extends Observable {
private _counter: number;
private _message: string;
public myObj = {ala: 3, bala: "bruh"};
constructor() {
super();
// Initialize default values.
this._counter = 42;
this.updateMessage();
console.dir(this.myObj);
}
get message(): string {
return this._message;
}
set message(value: string) {
if (this._message !== value) {
this._message = value;
this.notifyPropertyChange('message', value)
}
}
public onTap() {
this._counter--;
this.updateMessage();
}
private updateMessage() {
if (this._counter <= 0) {
this.message = 'Hoorraaay! You unlocked the NativeScript clicker achievement!';
} else {
this.message = `${this._counter} taps left`;
}
}
}