diff options
author | Eleanor Eng <eleanoreng@eleanors-mbp.devices.brown.edu> | 2019-02-25 18:58:45 -0500 |
---|---|---|
committer | Eleanor Eng <eleanoreng@eleanors-mbp.devices.brown.edu> | 2019-02-25 18:58:45 -0500 |
commit | 8d3ebd1eb393baf37932d021d6da79d46ef96a03 (patch) | |
tree | f6e0ef0cce9041525bcd5f6e0a37eee9226a9896 /src/fields/Field.ts | |
parent | fa2be8b245e4ed69b771e70a98e65176785751eb (diff) | |
parent | 292ff1a8d75f8b15f9388d2c577e09a13836d5dc (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into contextMenu
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 |