From 92bad631451c7ee28bf0bc61b55d45fa743bc08a Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Thu, 9 Mar 2023 18:44:43 +0100 Subject: [PATCH] add docs: tr.changes should only be computed during the event --- src/utils/YEvent.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/utils/YEvent.js b/src/utils/YEvent.js index 5d33ef67..ac877bc5 100644 --- a/src/utils/YEvent.js +++ b/src/utils/YEvent.js @@ -130,6 +130,11 @@ export class YEvent { } /** + * This is a computed property. Note that this can only be safely computed during the + * event call. Computing this property after other changes happened might result in + * unexpected behavior (incorrect computation of deltas). A safe way to collect changes + * is to store the `changes` or the `delta` object. Avoid storing the `transaction` object. + * * @type {Array<{insert?: string | Array | object | AbstractType, retain?: number, delete?: number, attributes?: Object}>} */ get delta () { @@ -149,6 +154,11 @@ export class YEvent { } /** + * This is a computed property. Note that this can only be safely computed during the + * event call. Computing this property after other changes happened might result in + * unexpected behavior (incorrect computation of deltas). A safe way to collect changes + * is to store the `changes` or the `delta` object. Avoid storing the `transaction` object. + * * @type {{added:Set,deleted:Set,keys:Map,delta:Array<{insert?:Array|string, delete?:number, retain?:number}>}} */ get changes () {