diff --git a/packages/dds/tree/src/core/tree/anchorSet.ts b/packages/dds/tree/src/core/tree/anchorSet.ts index c1cd7b6f3c75..01ef0574f629 100644 --- a/packages/dds/tree/src/core/tree/anchorSet.ts +++ b/packages/dds/tree/src/core/tree/anchorSet.ts @@ -104,18 +104,6 @@ export interface AnchorEvents { */ childrenChanging(anchor: AnchorNode): void; - /** - * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if one or more of this node's - * direct children just changed due to updates from the batch. - * - * @remarks - * Does not include edits of child subtrees: instead only includes changes to nodes which are direct children in this - * node's fields. - * - * Compare to {@link AnchorEvents.childrenChangedAfterBatch} which is emitted after the whole batch has been applied. - */ - childrenChanged(anchor: AnchorNode): void; - /** * Emitted after a batch of changes has been applied (i.e. when a delta visit completes), if one or more of this node's * direct children changed due to updates from the batch. @@ -132,36 +120,6 @@ export interface AnchorEvents { changedFields: ReadonlySet; }): void; - /** - * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if something in the subtree - * rooted at `anchor` _may_ be about to change due to updates from the batch. - * - * @remarks - * Called on every parent (transitively) when a change is occurring. - */ - subtreeChanging(anchor: AnchorNode): void; - - /** - * Emitted in the middle of applying a batch of changes (i.e. during a delta a visit), if something in the subtree - * rooted at `anchor` _may_ have just changed due to updates from the batch. - * - * @remarks - * While this event is always emitted in the presence of changes to the subtree, - * it may also be emitted even though no changes have been made to the subtree. - * It may be emitted multiple times within the application of a single edit or transaction. - * - * If this event is emitted by a node, it will later be emitted by all its ancestors up to the root as well, at - * least once on each ancestor. - * - * Compare to {@link AnchorEvents.subtreeChangedAfterBatch} which is emitted after the whole batch has been applied. - * - * @privateRemarks - * The delta visit algorithm is complicated and it may fire this event multiple times for the same change to a node. - * The change to the tree may not be visible until the event fires for the last time. - * Refer to the documentation of the delta visit algorithm for more details. - */ - subtreeChanged(anchor: AnchorNode): void; - /** * Emitted after a batch of changes has been applied (i.e. when a delta visit completes), if something in the subtree * rooted at `anchor` changed due to updates from the batch. @@ -170,13 +128,6 @@ export interface AnchorEvents { * If this event is emitted by a node, it will later be emitted by all its ancestors up to the root as well, from bottom to top. * * This event is guaranteed to be emitted on a given node only once per batch. - * - * Compare to {@link AnchorEvents.subtreeChanged} which is emitted in the middle of the batch/delta-visit. - * - * @privateRemarks - * Note that because this is fired after the full batch of changes is applied, it guarantees that something in the - * subtree changed, compared to {@link AnchorEvents.subtreeChanged} or {@link AnchorEvents.subtreeChanging} which - * fire when something _may_ have changed or _may_ be about to change. */ subtreeChangedAfterBatch(): void; } @@ -192,11 +143,6 @@ export interface AnchorEvents { * - Add more events. */ export interface AnchorSetRootEvents { - /** - * What children are at the root is changing. - */ - childrenChanging(anchors: AnchorSet): void; - /** * Something in the tree is changing. */ @@ -798,10 +744,7 @@ export class AnchorSet implements AnchorLocator { } }, notifyChildrenChanging(): void { - this.maybeWithNode( - (p) => p.events.emit("childrenChanging", p), - () => this.anchorSet.#events.emit("childrenChanging", this.anchorSet), - ); + this.maybeWithNode((p) => p.events.emit("childrenChanging", p)); }, notifyChildrenChanged(): void { this.maybeWithNode( @@ -810,7 +753,6 @@ export class AnchorSet implements AnchorLocator { this.parentField !== undefined, 0xa24 /* Must be in a field to modify its contents */, ); - p.events.emit("childrenChanged", p); this.bufferedEvents.push({ node: p, event: "childrenChangedAfterBatch", @@ -909,17 +851,12 @@ export class AnchorSet implements AnchorLocator { parentIndex: index, }; this.parentField = undefined; - this.maybeWithNode((p) => { - p.events.emit("subtreeChanging", p); - }); this.currentDepth++; }, exitNode(index: number): void { assert(this.parent !== undefined, 0x3ac /* Must have parent node */); if (this.depthThresholdForSubtreeChanged === this.currentDepth) { this.maybeWithNode((p) => { - p.events.emit("subtreeChanged", p); - this.bufferedEvents.push({ node: p, event: "subtreeChangedAfterBatch", diff --git a/packages/dds/tree/src/test/shared-tree/treeCheckout.spec.ts b/packages/dds/tree/src/test/shared-tree/treeCheckout.spec.ts index 88c16ec69a28..3497de45567a 100644 --- a/packages/dds/tree/src/test/shared-tree/treeCheckout.spec.ts +++ b/packages/dds/tree/src/test/shared-tree/treeCheckout.spec.ts @@ -87,9 +87,6 @@ describe("sharedTreeView", () => { const anchorNode = getOrCreateInnerNode(root).anchorNode; const log: string[] = []; const unsubscribe = anchorNode.events.on("childrenChanging", () => log.push("change")); - const unsubscribeSubtree = anchorNode.events.on("subtreeChanging", () => { - log.push("subtree"); - }); const unsubscribeAfter = view.checkout.events.on("afterBatch", () => log.push("after")); log.push("editStart"); root.x = 5; @@ -97,22 +94,15 @@ describe("sharedTreeView", () => { root.x = 6; log.push("unsubscribe"); unsubscribe(); - unsubscribeSubtree(); unsubscribeAfter(); log.push("editStart"); root.x = 7; assert.deepEqual(log, [ "editStart", - "subtree", - "change", - "subtree", "change", "after", "editStart", - "subtree", - "change", - "subtree", "change", "after", "unsubscribe", @@ -131,9 +121,6 @@ describe("sharedTreeView", () => { const unsubscribe = anchorNode.events.on("childrenChanging", (upPath) => log.push(`change-${String(upPath.parentField)}-${upPath.parentIndex}`), ); - const unsubscribeSubtree = anchorNode.events.on("subtreeChanging", (upPath) => { - log.push(`subtree-${String(upPath.parentField)}-${upPath.parentIndex}`); - }); const unsubscribeAfter = view.checkout.events.on("afterBatch", () => log.push("after")); log.push("editStart"); root.x = 5; @@ -141,22 +128,15 @@ describe("sharedTreeView", () => { root.x = 6; log.push("unsubscribe"); unsubscribe(); - unsubscribeSubtree(); unsubscribeAfter(); log.push("editStart"); root.x = 7; assert.deepEqual(log, [ "editStart", - "subtree-rootFieldKey-0", - "change-rootFieldKey-0", - "subtree-rootFieldKey-0", "change-rootFieldKey-0", "after", "editStart", - "subtree-rootFieldKey-0", - "change-rootFieldKey-0", - "subtree-rootFieldKey-0", "change-rootFieldKey-0", "after", "unsubscribe", diff --git a/packages/dds/tree/src/test/tree/anchorSet.spec.ts b/packages/dds/tree/src/test/tree/anchorSet.spec.ts index 066ec6b827da..61b641b4e6ce 100644 --- a/packages/dds/tree/src/test/tree/anchorSet.spec.ts +++ b/packages/dds/tree/src/test/tree/anchorSet.spec.ts @@ -446,11 +446,10 @@ describe("AnchorSet", () => { }); }); - it("triggers childrenChanging, childrenChanged, treeChanging, subtreeChanging, and afterDestroy callbacks", () => { + it("triggers childrenChanging, treeChanging, and afterDestroy callbacks", () => { // AnchorSet does not guarantee event ordering within a batch so use UnorderedTestLogger. const log = new UnorderedTestLogger(); const anchors = new AnchorSet(); - anchors.events.on("childrenChanging", log.logger("root childrenChange")); anchors.events.on("treeChanging", log.logger("root treeChange")); const detachMark: DeltaMark = { @@ -471,8 +470,6 @@ describe("AnchorSet", () => { const node0 = anchors.locate(anchor0) ?? assert.fail(); node0.events.on("childrenChanging", log.logger("childrenChanging")); - node0.events.on("childrenChanged", log.logger("childrenChanged")); - node0.events.on("subtreeChanging", log.logger("subtreeChange")); node0.events.on("afterDestroy", log.logger("afterDestroy")); log.expect([]);