TreeAlpha Interface
Extensions to Tree and TreeBeta which are not yet stable.
For more information about our API support guarantees, see here.
Signature
/** @sealed */
export interface TreeAlpha
Remarks
Use via the TreeAlpha singleton.
Methods
Method | Alerts | Return Type | Description |
---|---|---|---|
branch(node) | Alpha |
TreeBranch | undefined | Retrieve the branch, if any, for the given node. |
create(schema, data) | Alpha |
Unhydrated<TSchema extends ImplicitFieldSchema ? TreeFieldFromImplicitField<TSchema> : TreeNode | TreeLeafValue | undefined> | Construct tree content that is compatible with the field defined by the provided schema . |
exportCompressed(tree, options) | Alpha |
JsonCompatible<IFluidHandle> | Export the content of the provided tree in a compressed JSON compatible format. |
exportConcise(node, options) | Alpha |
ConciseTree | Copy a snapshot of the current version of a TreeNode into a ConciseTree. |
exportConcise(node, options) | Alpha |
ConciseTree | undefined | Copy a snapshot of the current version of a TreeNode into a ConciseTree, allowing undefined. |
exportVerbose(node, options) | Alpha |
VerboseTree | Copy a snapshot of the current version of a TreeNode into a JSON compatible plain old JavaScript Object (except for IFluidHandles). Uses the VerboseTree format, with an explicit type on every node. |
importCompressed(schema, compressedData, options) | Alpha |
Unhydrated<TreeFieldFromImplicitField<TSchema>> | Import data encoded by exportCompressed(tree, options). |
importConcise(schema, data) | Alpha |
Unhydrated<TSchema extends ImplicitFieldSchema ? TreeFieldFromImplicitField<TSchema> : TreeNode | TreeLeafValue | undefined> | Less type safe version of create(schema, data), suitable for importing data. |
importVerbose(schema, data, options) | Alpha |
Unhydrated<TreeFieldFromImplicitField<TSchema>> | Construct tree content compatible with a field defined by the provided schema . |
Method Details
branch
Retrieve the branch, if any, for the given node.
For more information about our API support guarantees, see here.
Signature
branch(node: TreeNode): TreeBranch | undefined;
Remarks
If the node has already been inserted into the tree, this will return the branch associated with that node's view. Otherwise, it will return undefined
(because the node has not yet been inserted and is therefore not part of a branch or view).
This does not fork a new branch, but rather retrieves the _existing_ branch for the node. To create a new branch, use e.g. `myBranch.fork()`.
Parameters
Parameter | Type | Description |
---|---|---|
node | TreeNode | The node to query |
Returns
Return type: TreeBranch | undefined
create
Construct tree content that is compatible with the field defined by the provided schema
.
For more information about our API support guarantees, see here.
Signature
create<const TSchema extends ImplicitFieldSchema | UnsafeUnknownSchema>(schema: UnsafeUnknownSchema extends TSchema ? ImplicitFieldSchema : TSchema & ImplicitFieldSchema, data: InsertableField<TSchema>): Unhydrated<TSchema extends ImplicitFieldSchema ? TreeFieldFromImplicitField<TSchema> : TreeNode | TreeLeafValue | undefined>;
Type Parameters
Parameter | Constraint | Description |
---|---|---|
TSchema | ImplicitFieldSchema | UnsafeUnknownSchema |
Remarks
When providing a TreeNodeSchemaClass, this is the same as invoking its constructor except that an unhydrated node can also be provided. This function exists as a generalization that can be used in other cases as well, such as when undefined
might be allowed (for an optional field), or when the type should be inferred from the data when more than one type is possible.
Like with TreeNodeSchemaClass's constructor, it's an error to provide an existing node to this API. For that case, use clone(node).
Parameters
Parameter | Type | Description |
---|---|---|
schema | UnsafeUnknownSchema extends TSchema ? ImplicitFieldSchema : TSchema & ImplicitFieldSchema | The schema for what to construct. As this is an ImplicitFieldSchema, a FieldSchema, TreeNodeSchema or AllowedTypes array can be provided. |
data | InsertableField<TSchema> | The data used to construct the field content. |
Returns
Return type: Unhydrated<TSchema extends ImplicitFieldSchema ? TreeFieldFromImplicitField<TSchema> : TreeNode | TreeLeafValue | undefined>
exportCompressed
Export the content of the provided tree
in a compressed JSON compatible format.
For more information about our API support guarantees, see here.
Signature
exportCompressed(tree: TreeNode | TreeLeafValue, options: {
oldestCompatibleClient: FluidClientVersion;
idCompressor?: IIdCompressor;
}): JsonCompatible<IFluidHandle>;
Remarks
If an idCompressor
is provided, it will be used to compress identifiers and thus will be needed to decompress the data.
Always uses "stored" keys. See useStoredKeys for details.
Parameters
Parameter | Type | Description |
---|---|---|
tree | TreeNode | TreeLeafValue | |
options | { oldestCompatibleClient: FluidClientVersion; idCompressor?: IIdCompressor; } |