aboutsummaryrefslogtreecommitdiff
path: root/src/fields/Document.ts
diff options
context:
space:
mode:
authorSam Wilkins <abdullah_ahmed@brown.edu>2019-03-12 16:28:28 -0400
committerSam Wilkins <abdullah_ahmed@brown.edu>2019-03-12 16:28:28 -0400
commit884647be52cf6b3c7e3132dce7d9133875d9a9cd (patch)
treeaf5041ec3ec76fb45944c2a81e3716b3a866c3dd /src/fields/Document.ts
parentd2383acb7123c0c032822745171f7df8baa77518 (diff)
parent91338b2cea4f006e5813145009cb471b17679cd7 (diff)
Merged with master, refactor with route store
Diffstat (limited to 'src/fields/Document.ts')
-rw-r--r--src/fields/Document.ts8
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,