diff options
author | bobzel <zzzman@gmail.com> | 2022-12-21 19:38:29 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2022-12-21 19:38:29 -0500 |
commit | 631826f13c67aef760bc7e76665e152f1f63bf5b (patch) | |
tree | 8733aac0da4fcdf12277bf204a63c68ac7ac20aa /src/fields/Proxy.ts | |
parent | e373e66f8ed06f4501e00af8348f15ad113c7424 (diff) | |
parent | 4c0de84cf9a3d5be2f5058d514c8ca58e2004a4b (diff) |
cleaning up proxys and getFieldRef hopefully to be more understandable and efficient
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 }; + } } } |