aboutsummaryrefslogtreecommitdiff
path: root/src/fields/Field.ts
diff options
context:
space:
mode:
authorab <abdullah_ahmed@brown.edu>2019-03-09 15:59:36 -0500
committerab <abdullah_ahmed@brown.edu>2019-03-09 15:59:36 -0500
commit30b082a9d94465ae24d9c392843518e8df2c9d66 (patch)
tree01c464b96defe06b2c99e8e298b9287901d4d9b0 /src/fields/Field.ts
parent12d20ab1b9b843d816bde445d9b67b3aa6abc6ae (diff)
parent96eede5f7d1706a3f7ac6ee02a85bb3da217f467 (diff)
merging
Diffstat (limited to 'src/fields/Field.ts')
-rw-r--r--src/fields/Field.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/fields/Field.ts b/src/fields/Field.ts
index 4a3968699..d48509a47 100644
--- a/src/fields/Field.ts
+++ b/src/fields/Field.ts
@@ -1,5 +1,7 @@
import { Utils } from "../Utils";
+import { Types } from "../server/Message";
+import { computed } from "mobx";
export function Cast<T extends Field>(field: FieldValue<Field>, ctor: { new(): T }): Opt<T> {
if (field) {
@@ -19,7 +21,13 @@ export type FieldValue<T> = Opt<T> | FIELD_WAITING;
export abstract class Field {
//FieldUpdated: TypedEvent<Opt<FieldUpdatedArgs>> = new TypedEvent<Opt<FieldUpdatedArgs>>();
+ init(callback: (res: Field) => any) {
+ callback(this);
+ }
+
private id: FieldId;
+
+ @computed
get Id(): FieldId {
return this.id;
}
@@ -47,6 +55,8 @@ export abstract class Field {
return this.id === other.id;
}
+ abstract UpdateFromServer(serverData: any): void;
+
abstract ToScriptString(): string;
abstract TrySetValue(value: any): boolean;
@@ -55,4 +65,5 @@ export abstract class Field {
abstract Copy(): Field;
+ abstract ToJson(): { _id: string, type: Types, data: any }
} \ No newline at end of file