diff options
author | bobzel <zzzman@gmail.com> | 2023-01-02 15:05:51 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-02 15:05:51 -0500 |
commit | 9211251c8a632ef84198253a0d3086df11af9ead (patch) | |
tree | 378330aeaecdd68e291dfa0b68c339dfa1c233da /src/fields/Proxy.ts | |
parent | 4c0de84cf9a3d5be2f5058d514c8ca58e2004a4b (diff) | |
parent | da9aef9e4cda036264801191361c1ecfacd9ba0b (diff) |
Merge pull request #157 from brown-dash/robustness
cleaning up ACLs for performance and clarity
Diffstat (limited to 'src/fields/Proxy.ts')
-rw-r--r-- | src/fields/Proxy.ts | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/fields/Proxy.ts b/src/fields/Proxy.ts index 1266e6e3c..55d1d9ea4 100644 --- a/src/fields/Proxy.ts +++ b/src/fields/Proxy.ts @@ -5,9 +5,8 @@ import { observable, action, runInAction, computed } from 'mobx'; import { DocServer } from '../client/DocServer'; import { RefField } from './RefField'; import { ObjectField } from './ObjectField'; -import { Id, Copy, ToScriptString, ToString } from './FieldSymbols'; +import { Id, Copy, ToScriptString, ToString, ToValue } from './FieldSymbols'; import { scriptingGlobal } from '../client/util/ScriptingGlobals'; -import { Plugins } from './util'; function deserializeProxy(field: any) { if (!field.cache.field) { @@ -30,6 +29,10 @@ export class ProxyField<T extends RefField> extends ObjectField { } } + [ToValue](doc: any) { + return ProxyField.toValue(this); + } + [Copy]() { if (this.cache.field) return new ProxyField<T>(this.cache.field); return new ProxyField<T>(this.fieldId); @@ -105,12 +108,10 @@ export namespace ProxyField { } } - export function initPlugin() { - Plugins.addGetterPlugin((doc, _, value) => { - if (useProxy && value instanceof ProxyField) { - return { value: value.value }; - } - }); + export function toValue(value: any) { + if (useProxy) { + return { value: value.value }; + } } } |