TreeChangeEventsAlpha Interface
Extension of TreeChangeEvents with a richer nodeChanged event and a delta-carrying treeChanged event for array nodes.
To use, import via fluid-framework/alpha.
For more information about our API support guarantees, see here.
This type is "sealed," meaning that code outside of the library defining it should not implement or extend it. Future versions of this type may add members or make typing of readonly members more specific.
Signature
/** @sealed */
export interface TreeChangeEventsAlpha<TNode extends TreeNode = TreeNode> extends TreeChangeEvents
Extends: TreeChangeEvents
Type Parameters
| Parameter | Constraint | Default | Description |
|---|---|---|---|
| TNode | TreeNode | TreeNode |
Remarks
Provides a nodeChanged event that includes a delta payload for array nodes and requires changedProperties for object, map, and record nodes. Also provides a treeChanged event that, for array nodes, carries a NodeChangedDataDelta payload describing both shallow and deep changes. For non-array nodes, the treeChanged signature is the same as the base event.
Use via TreeAlpha.on.
Properties
| Property | Alerts | Type | Description |
|---|---|---|---|
| nodeChanged | Alpha | (data: NodeChangedDataAlpha<TNode>) => void | Emitted when a shallow change occurs on this node, i.e., when the node's direct children change. |
| treeChanged | Alpha | TNode extends WithType<string, NodeKind.Array> ? (data: NodeChangedDataTreeDelta) => void : TreeChangeEventsBeta<TNode>["treeChanged"] | Emitted when something in the subtree rooted at this node changes. |
Property Details
nodeChanged
Emitted when a shallow change occurs on this node, i.e., when the node's direct children change.
For more information about our API support guarantees, see here.
Signature
nodeChanged: (data: NodeChangedDataAlpha<TNode>) => void;
Type: (data: NodeChangedDataAlpha<TNode>) => void
Remarks
For array nodes: the event data includes a delta payload as a sequence of ArrayNodeDeltaOp values. Does not fire for deep changes (e.g. a property of an array element changed without any shallow array change). Subscribe to treeChanged on the array to receive a delta for those cases as well.
For object, map, and record nodes: the event data includes changedProperties.
treeChanged
Emitted when something in the subtree rooted at this node changes.
For more information about our API support guarantees, see here.
Signature
treeChanged: TNode extends WithType<string, NodeKind.Array> ? (data: NodeChangedDataTreeDelta) => void : TreeChangeEventsBeta<TNode>["treeChanged"];
Type: TNode extends WithType<string, NodeKind.Array> ? (data: NodeChangedDataTreeDelta) => void : TreeChangeEventsBeta<TNode>["treeChanged"]
Remarks
For array nodes: emitted when any change occurred within the array, including both shallow changes (insert, remove, move) and deep changes (e.g. a property of an element changed). The event data carries a delta payload describing what changed. The delta uses subtreeChanged to flag elements that have deep changes, without describing the details of those deep changes. To inspect deep changes, subscribe to nodeChanged or treeChanged on the individual element nodes.
When this array is nested inside another array, the outer array's treeChanged still fires with a delta, but that delta only shows subtreeChanged: true for the element position containing this inner array — it does not include the inner array's detailed insert/remove/retain ops. To receive those detailed ops, subscribe to treeChanged directly on the inner array. Ancestor non-array nodes still receive the base (no-payload) treeChanged via normal subtree propagation.
For non-array nodes: same as the base treeChanged().