diff options
author | ab <abdullah_ahmed@brown.edu> | 2019-03-09 16:06:18 -0500 |
---|---|---|
committer | ab <abdullah_ahmed@brown.edu> | 2019-03-09 16:06:18 -0500 |
commit | a2b90031fe06701b0ecc7c6fa3b48c933e4d37b8 (patch) | |
tree | 541052a97652ad25b0829685f205ec35d3976743 /src/fields/Field.ts | |
parent | b72ff1323bc76dc244ebe50893aa78064fd836c7 (diff) | |
parent | 09928503be98d605052fba65dcd2f91f9b056f23 (diff) |
fix
Diffstat (limited to 'src/fields/Field.ts')
-rw-r--r-- | src/fields/Field.ts | 11 |
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 |