aboutsummaryrefslogtreecommitdiff
path: root/src/fields/Document.ts
diff options
context:
space:
mode:
authorHannah Chow <hannah_chow@brown.edu>2019-03-11 17:11:43 -0400
committerHannah Chow <hannah_chow@brown.edu>2019-03-11 17:11:43 -0400
commit281b4e05a7fbd6b038782d9708839bf7edcf398d (patch)
treed91d9d4b45571b35c6b84d31de8af0487c4aaa2e /src/fields/Document.ts
parentfe4f37c9986e0a6500d63b46e2238b0e0efb102b (diff)
parent618e66a5a070f1aac9224bd3f44b76a5ac314bfa (diff)
uhhhh
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,