diff options
author | Sam Wilkins <abdullah_ahmed@brown.edu> | 2019-05-08 23:16:24 -0400 |
---|---|---|
committer | Sam Wilkins <abdullah_ahmed@brown.edu> | 2019-05-08 23:16:24 -0400 |
commit | 508410d810f61b8f8602dedbbba3e0736c1f5ba3 (patch) | |
tree | b6de0f335ed187f7e795025ba9a304b3146fc6a2 /src/new_fields/Doc.ts | |
parent | 086391b7e45ed4b3cb29602a776f5812f142fff2 (diff) | |
parent | 890d43c23c5aaafc8ebc2978cd1ad2e19bfcd830 (diff) |
Working implementation of remote cursors
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r-- | src/new_fields/Doc.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 3055af1bf..f844dad6e 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -25,10 +25,17 @@ export type FieldResult<T extends Field = Field> = Opt<T> | FieldWaiting<Extract export const Update = Symbol("Update"); export const Self = Symbol("Self"); -const SelfProxy = Symbol("SelfProxy"); +export const SelfProxy = Symbol("SelfProxy"); export const WidthSym = Symbol("Width"); export const HeightSym = Symbol("Height"); +export function DocListCast(field: FieldResult): Promise<Doc[] | undefined>; +export function DocListCast(field: FieldResult, defaultValue: Doc[]): Promise<Doc[]>; +export function DocListCast(field: FieldResult, defaultValue?: Doc[]) { + const list = Cast(field, listSpec(Doc)); + return list ? Promise.all(list) : Promise.resolve(defaultValue); +} + @Deserializable("doc").withFields(["id"]) export class Doc extends RefField { constructor(id?: FieldId, forceSave?: boolean) { @@ -186,7 +193,7 @@ export namespace Doc { UndoManager.RunInBatch(() => { let linkDoc = Docs.TextDocument({ width: 100, height: 30, borderRounding: -1 }); //let linkDoc = new Doc; - linkDoc.title = "-link name-"; + linkDoc.proto!.title = "-link name-"; linkDoc.linkDescription = ""; linkDoc.linkTags = "Default"; @@ -215,7 +222,6 @@ export namespace Doc { return undefined; } const delegate = new Doc(); - //TODO Does this need to be doc[Self]? delegate.proto = doc; return delegate; } |