blob: 923bc335c20d9e55c345025c681fd2ae193cfdf7 (
plain)
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
|
import { FieldController } from "./FieldController"
import { observable, computed, action } from "mobx";
export abstract class BasicFieldController<T> extends FieldController {
constructor(data: T) {
super();
this.data = data;
}
@observable
private data:T;
@computed
get Data(): T {
return this.data;
}
set Data(value: T) {
if(this.data === value) {
return;
}
this.data = value;
}
@action
TrySetValue(value: any): boolean {
if (typeof value == typeof this.data) {
this.Data = value;
return true;
}
return false;
}
GetValue(): any {
return this.Data;
}
}
|