diff options
| author | Brandon <brandon_li@brown.edu> | 2019-03-11 18:27:22 -0400 |
|---|---|---|
| committer | Brandon <brandon_li@brown.edu> | 2019-03-11 18:27:22 -0400 |
| commit | c1d2a28123f4c9290fe8346730976687671f4042 (patch) | |
| tree | 7d6ad3ca7c8216947ec7563963a55a5b9c39d848 /src/fields/Document.ts | |
| parent | c9ae6d447c151ffbc6691a095802489038d004c1 (diff) | |
| parent | 618e66a5a070f1aac9224bd3f44b76a5ac314bfa (diff) | |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into kvp
Diffstat (limited to 'src/fields/Document.ts')
| -rw-r--r-- | src/fields/Document.ts | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/fields/Document.ts b/src/fields/Document.ts index 2e873439c..25e239417 100644 --- a/src/fields/Document.ts +++ b/src/fields/Document.ts @@ -1,6 +1,6 @@ import { Key } from "./Key" import { KeyStore } from "./KeyStore"; -import { Field, Cast, FieldWaiting, FieldValue, FieldId } from "./Field" +import { Field, Cast, FieldWaiting, FieldValue, FieldId, Opt } from "./Field" import { NumberField } from "./NumberField"; import { ObservableMap, computed, action } from "mobx"; import { TextField } from "./TextField"; @@ -128,6 +128,12 @@ export class Document extends Field { return false; } + GetTAsync<T extends Field>(key: Key, ctor: { new(): T }, callback: (field: Opt<T>) => void): boolean { + return this.GetAsync(key, (field) => { + callback(Cast(field, ctor)); + }) + } + /** * Same as {@link Document#GetAsync}, except a field of the given type * will be created if there is no field associated with the given key, |
