TreeViewBeta Interface
TreeView with additional beta APIs.
To use, import via fluid-framework/beta.
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 TreeViewBeta<in out TSchema extends ImplicitFieldSchema> extends TreeView<TSchema>, TreeBranch
Extends: TreeView<TSchema>, TreeBranch
Type Parameters
| Parameter | Constraint | Description |
|---|---|---|
| TSchema | ImplicitFieldSchema |
Methods
| Method | Alerts | Return Type | Description |
|---|---|---|---|
| fork() | Beta | ReturnType<TreeBranch["fork"]> & TreeViewBeta<TSchema> | |
| runTransaction(transaction, params) | Beta | TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult | Run a synchronous transaction which groups sequential edits to the tree into a single atomic edit if possible. |
| runTransactionAsync(transaction, params) | Beta | Promise<TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult> | An asynchronous version of runTransaction. |
Method Details
fork
For more information about our API support guarantees, see here.
Signature
fork(): ReturnType<TreeBranch["fork"]> & TreeViewBeta<TSchema>;
Returns
Return type: ReturnType<TreeBranch["fork"]> & TreeViewBeta<TSchema>
runTransaction
Run a synchronous transaction which groups sequential edits to the tree into a single atomic edit if possible.
For more information about our API support guarantees, see here.
Signature
runTransaction<TOut extends TransactionCallbackStatusBeta<unknown, unknown> | VoidTransactionCallbackStatusBeta | void>(transaction: () => TOut, params?: RunTransactionParamsBeta): TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult;
Type Parameters
| Parameter | Constraint | Description |
|---|---|---|
| TOut | TransactionCallbackStatusBeta<unknown, unknown> | VoidTransactionCallbackStatusBeta | void |
Remarks
All of the changes in the transaction are applied synchronously and therefore no other changes from a remote client can be interleaved with those changes. Note that this is guaranteed by Fluid for any sequence of changes that are submitted synchronously, whether in a transaction or not.
Change events will be emitted for changed nodes on this client _as each edit happens_, just as they would be if the changes were made outside of a transaction. Any other/future clients or contexts will process the transaction "squashed", i.e. they will apply its changes all at once, emitting only a single event per node (even if that node was edited multiple times in the transaction). Edits to the tree are not permitted within these event callbacks, therefore no other local changes from this client will be interleaved with the changes in this transaction.
Using a transaction has the following additional consequences:
- If reverted (e.g. via an "undo" operation), all the changes in the transaction are reverted together. Only the "outermost" transaction commits a change to the synchronized tree state and therefore only the outermost transaction can be reverted. If a transaction is started and completed while another transaction is already in progress, then the inner transaction will be reverted together with the outer transaction. - The internal data representation of a transaction with many changes is generally smaller and more efficient than that of the changes when separate.
If the transaction is rolled back, a corresponding `changed` event will also be emitted for the rollback.
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| transaction | () => TOut | The function to run as the body of the transaction, which may optionally return a value or rollback signal. It may optionally return a value, which will be returned by the runTransaction call. | |
| params | optional | RunTransactionParamsBeta | Optional parameters for the transaction. |
Returns
A value indicating whether or not the transaction succeeded, and containing the value returned by transaction.
Return type: TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult
runTransactionAsync
An asynchronous version of runTransaction.
For more information about our API support guarantees, see here.
Signature
runTransactionAsync<TOut extends TransactionCallbackStatusBeta<unknown, unknown> | VoidTransactionCallbackStatusBeta | void>(transaction: () => Promise<TOut>, params?: RunTransactionParamsBeta): Promise<TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult>;
Type Parameters
| Parameter | Constraint | Description |
|---|---|---|
| TOut | TransactionCallbackStatusBeta<unknown, unknown> | VoidTransactionCallbackStatusBeta | void |
Remarks
As with synchronous transactions, all of the changes in an asynchronous transaction are treated as a unit. Therefore, no other changes (either from this client or from a remote client) can be interleaved with the transaction changes.
Unlike with synchronous transactions, it is possible that other changes (e.g. from a remote client) may be applied to the branch while this transaction is in progress. Those other changes will be not be reflected on the branch until after this transaction completes, at which point the transaction changes will be applied after those other changes.
An asynchronous transaction may not be started while any other transaction is in progress in this view.
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| transaction | () => Promise<TOut> | ||
| params | optional | RunTransactionParamsBeta |
Returns
Return type: Promise<TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult>