TreeBeta Interface
Extensions to Tree which are not yet stable.
For more information about our API support guarantees, see here.
Signature
/** @sealed */
export interface TreeBeta
Remarks
Use via the TreeBeta singleton.
Methods
Method | Alerts | Return Type | Description |
---|---|---|---|
clone(node) | Beta |
TreeFieldFromImplicitField<TSchema> | Clones the persisted data associated with a node. |
on(node, eventName, listener) | Beta |
() => void | Register an event listener on the given node. |
Method Details
clone
Clones the persisted data associated with a node.
For more information about our API support guarantees, see here.
Signature
clone<const TSchema extends ImplicitFieldSchema>(node: TreeFieldFromImplicitField<TSchema>): TreeFieldFromImplicitField<TSchema>;
Type Parameters
Parameter | Constraint | Description |
---|---|---|
TSchema | ImplicitFieldSchema |
Remarks
Some key things to note:
-
Local state, such as properties added to customized schema classes, will not be cloned. However, they will be initialized to their default state just as if the node had been created via its constructor.
-
Value node types (i.e., numbers, strings, booleans, nulls and Fluid handles) will be returned as is.
-
The identifiers in the node's subtree will be preserved, i.e., they are not replaced with new values.
Parameters
Parameter | Type | Description |
---|---|---|
node | TreeFieldFromImplicitField<TSchema> | The node to clone. |
Returns
A new unhydrated node with the same persisted data as the original node.
Return type: TreeFieldFromImplicitField<TSchema>
on
Register an event listener on the given node.
For more information about our API support guarantees, see here.
Signature
on<K extends keyof TreeChangeEventsBeta<TNode>, TNode extends TreeNode>(node: TNode, eventName: K, listener: NoInfer<TreeChangeEventsBeta<TNode>[K]>): () => void;
Type Parameters
Parameter | Constraint | Description |
---|---|---|
K | keyof TreeChangeEventsBeta<TNode> | |
TNode | TreeNode |
Parameters
Parameter | Type | Description |
---|---|---|
node | TNode | The node whose events should be subscribed to. |
eventName | K | Which event to subscribe to. |
listener | NoInfer<TreeChangeEventsBeta<TNode>[K]> | The callback to trigger for the event. The tree can be read during the callback, but it is invalid to modify the tree during this callback. |
Returns
A callback function which will deregister the event. This callback should be called only once.
Return type: () => void