Skip to main content

UntypedTreeView Interface

An untyped view of a (version-control-style) branch of a SharedTree.

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 UntypedTreeView extends IDisposable

Extends: IDisposable

Remarks

An UntypedTreeView allows for the creation of branches and for those branches to later be merged.

The branch associated directly with the SharedTree is the "main" branch, and all other branches fork (directly or transitively) from that main branch.

See UntypedTreeViewAlpha for additional APIs that are in an earlier stage of development.

Methods

MethodAlertsReturn TypeDescription
dispose(error)BetavoidDispose of this view, cleaning up any resources associated with it.
fork()BetaUntypedTreeViewFork a new branch off of this branch which is based off of this branch's current state.
merge(view, disposeMerged)BetavoidApply all the new changes on the given view to this view.
rebaseOnto(view)BetavoidAdvance this view forward such that all new changes on the target view become part of this view.

Method Details

dispose

Dispose of this view, cleaning up any resources associated with it.

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

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

Signature

dispose(error?: Error): void;

Remarks

Views can also be automatically disposed when they are merged into another view.

Disposing branches is important to avoid consuming memory unnecessarily. In particular, the SharedTree retains all sequenced changes made to the tree since the "most-behind" view was created or last rebased.

The main view cannot be disposed - attempting to do so will have no effect.

Parameters

ParameterModifiersTypeDescription
erroroptionalErrorOptional error indicating the reason for the disposal, if the object was disposed as the result of an error.

fork

Fork a new branch off of this branch which is based off of this branch's current state.

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(): UntypedTreeView;

Remarks

Any changes to the tree on the new view will not apply to this view until the new view is e.g. merged back into this view. The view should be disposed when no longer needed, either explicitly or implicitly when merging into another view.

Returns

Return type: UntypedTreeView

merge

Apply all the new changes on the given view to this view.

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

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

Signature

merge(view: UntypedTreeView, disposeMerged?: boolean): void;

Remarks

All ongoing transactions (if any) in view will be committed before the merge.

Parameters

ParameterModifiersTypeDescription
viewUntypedTreeViewA view created by fork().
disposeMergedoptionalbooleanWhether or not to dispose view after the merge completes. Defaults to true. The main view cannot be disposed - attempting to do so will have no effect.

rebaseOnto

Advance this view forward such that all new changes on the target view become part of this view.

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

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

Signature

rebaseOnto(view: UntypedTreeView): void;

Remarks

After rebasing, this view will be "ahead" of the target view, that is, its unique changes will have been recreated as if they happened after all changes on the target view. This method may only be called on views produced via fork - attempting to rebase the main view will throw.

Rebasing long-lived branches is important to avoid consuming memory unnecessarily. In particular, the SharedTree retains all sequenced changes made to the tree since the "most-behind" branch was created or last rebased.

The main view cannot be rebased onto another view - attempting to do so will throw an error.

Parameters

ParameterTypeDescription
viewUntypedTreeViewThe view to rebase onto.