Packages > @fluidframework/tree > TreeChangeEvents

TreeChangeEvents Interface

A collection of events that can be raised by a TreeNode .

Signature

export interface TreeChangeEvents

Methods

Method Return Type Description
nodeChanged() void

Emitted by a node when a batch of changes is applied to it, where a change is:

- For an object node, when the value of one of its properties changes (i.e., the property's value is set to something else, including undefined).

- For an array node, when an element is added, removed, or moved.

- For a map node, when an entry is added, updated, or removed.

treeChanged() void Emitted by a node when something _may_ have changed anywhere in the subtree rooted at it.

Method Details

nodeChanged

Emitted by a node when a batch of changes is applied to it, where a change is:

  • For an object node, when the value of one of its properties changes (i.e., the property’s value is set to something else, including undefined).

  • For an array node, when an element is added, removed, or moved.

  • For a map node, when an entry is added, updated, or removed.

Signature

nodeChanged(): void;

Remarks

This event is not raised when:

  • Properties of a child node change. Notably, updates to an array node or a map node (like adding or removing elements/entries) will raise this event on the array/map node itself, but not on the node that contains the array/map node as one of its properties.

  • The node is moved to a different location in the tree or removed from the tree. In this case the event is raised on the _parent_ node, not the node itself.

For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in the client that made the original edit. While a batch of edits will as a whole update the tree to the appropriate end state, no guarantees are made about how many times this event will be raised during any intermediate states. When it is raised, the tree is guaranteed to be in-schema.

treeChanged

Emitted by a node when something _may_ have changed anywhere in the subtree rooted at it.

Signature

treeChanged(): void;

Remarks

This event is guaranteed to be emitted whenever the subtree _has_ changed. However, it might also be emitted when the subtree has no visible changes compared to before the event firing.

Consumers of this event have the guarantee that they won’t miss any changes, but should also handle the scenario where the event fires with no visible changes as well.

This event is not raised when the node itself is moved to a different location in the tree or removed from the tree. In that case it is raised on the _parent_ node, not the node itself.

The node itself is part of the subtree, so this event will be emitted even if the only changes are to the properties of the node itself.

For remote edits, this event is not guaranteed to occur in the same order or quantity that it did in the client that made the original edit. While a batch of edits will as a whole update the tree to the appropriate end state, no guarantees are made about how many times this event will be raised during any intermediate states. When it is raised, the tree is guaranteed to be in-schema.