diff options
author | Tyler Schicke <tyler_schicke@brown.edu> | 2019-05-01 02:03:40 -0400 |
---|---|---|
committer | Tyler Schicke <tyler_schicke@brown.edu> | 2019-05-01 02:03:40 -0400 |
commit | ca4a0a6454e69f0eeabdfb6ec78f8ecd60e18b76 (patch) | |
tree | ec23b46418f56410463201e1fc9288ba8e3bdf26 /src/new_fields/Doc.ts | |
parent | 770f55f12398b5791cf3f861f3ea60fac8da626d (diff) |
Undo with lists is working better
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r-- | src/new_fields/Doc.ts | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 113380ce8..b2979af11 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -25,6 +25,7 @@ export type FieldResult<T extends Field = Field> = Opt<T> | FieldWaiting<Extract export const Update = Symbol("Update"); export const Self = Symbol("Self"); +const SelfProxy = Symbol("SelfProxy"); export const WidthSym = Symbol("Width"); export const HeightSym = Symbol("Height"); @@ -48,6 +49,7 @@ export class Doc extends RefField { deleteProperty: deleteProperty, defineProperty: () => { throw new Error("Currently properties can't be defined on documents using Object.defineProperty"); }, }); + this[SelfProxy] = doc; if (!id || forceSave) { DocServer.CreateField(SerializationHelper.Serialize(doc)); } @@ -68,7 +70,7 @@ export class Doc extends RefField { const field = value[key]; if (!(field instanceof ObjectField)) continue; field[Parent] = this[Self]; - field[OnUpdate] = updateFunction(this[Self], key, field); + field[OnUpdate] = updateFunction(this[Self], key, field, this[SelfProxy]); } } @@ -81,8 +83,9 @@ export class Doc extends RefField { } private [Self] = this; - public [WidthSym] = () => { return NumCast(this.__fields.width); } // bcz: is this the right way to access width/height? it didn't work with : this.width - public [HeightSym] = () => { return NumCast(this.__fields.height); } + private [SelfProxy]: any; + public [WidthSym] = () => NumCast(this.__fields.width); // bcz: is this the right way to access width/height? it didn't work with : this.width + public [HeightSym] = () => NumCast(this.__fields.height); } export namespace Doc { |