Thanks to visit codestin.com
Credit goes to fluidframework.com

Skip to main content

TreeViewBeta Interface

TreeView with additional beta APIs.

This API is provided as a beta preview and may change without notice.

To use, import via fluid-framework/beta.

For more information about our API support guarantees, see here.

Sealed

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

ParameterConstraintDescription
TSchemaImplicitFieldSchema

Methods

MethodAlertsReturn TypeDescription
fork()BetaReturnType<TreeBranch["fork"]> & TreeViewBeta<TSchema>
runTransaction(transaction, params)BetaTOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResultRun a synchronous transaction which groups sequential edits to the tree into a single atomic edit if possible.
runTransactionAsync(transaction, params)BetaPromise<TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult>An asynchronous version of runTransaction.

Method Details

fork

This API is provided as a beta preview and may change without notice.

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.

This API is provided as a beta preview and may change without notice.

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
ParameterConstraintDescription
TOutTransactionCallbackStatusBeta<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

ParameterModifiersTypeDescription
transaction() => TOutThe 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.
paramsoptionalRunTransactionParamsBetaOptional 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.

This API is provided as a beta preview and may change without notice.

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
ParameterConstraintDescription
TOutTransactionCallbackStatusBeta<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

ParameterModifiersTypeDescription
transaction() => Promise<TOut>
paramsoptionalRunTransactionParamsBeta

Returns

Return type: Promise<TOut extends TransactionCallbackStatusBeta<infer TSuccessValue, infer TFailureValue> ? TransactionValueResult<TSuccessValue, TFailureValue> : TransactionVoidResult>