diff options
author | andrewdkim <adkim414@gmail.com> | 2019-07-22 15:47:37 -0400 |
---|---|---|
committer | andrewdkim <adkim414@gmail.com> | 2019-07-22 15:47:37 -0400 |
commit | 5c0defdb56b4c31bb4ab2670990a51b6f05d1a5e (patch) | |
tree | 85f608ac6c5ce277f3ff3fa261ec8bb9fb22589d /src/new_fields/ScriptField.ts | |
parent | 9e093b9652750cfd102864c551ed8564a04df92e (diff) | |
parent | 291ae12b0c4587c4f656caac6d402413cc8ec76d (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into animationtimeline
Diffstat (limited to 'src/new_fields/ScriptField.ts')
-rw-r--r-- | src/new_fields/ScriptField.ts | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/new_fields/ScriptField.ts b/src/new_fields/ScriptField.ts index b5b1595cf..e8a1ea28a 100644 --- a/src/new_fields/ScriptField.ts +++ b/src/new_fields/ScriptField.ts @@ -5,6 +5,7 @@ import { serializable, createSimpleSchema, map, primitive, object, deserialize, import { Deserializable } from "../client/util/SerializationHelper"; import { Doc } from "../new_fields/Doc"; import { Plugins } from "./util"; +import { computedFn } from "mobx-utils"; function optional(propSchema: PropSchema) { return custom(value => { @@ -87,13 +88,13 @@ export class ScriptField extends ObjectField { @Deserializable("computed", deserializeScript) export class ComputedField extends ScriptField { //TODO maybe add an observable cache based on what is passed in for doc, considering there shouldn't really be that many possible values for doc - value(doc: Doc) { + value = computedFn((doc: Doc) => { const val = this.script.run({ this: doc }); if (val.success) { return val.result; } return undefined; - } + }); } export namespace ComputedField { |