Skip to main content

TreeView Interface

An editable view of a (version control style) branch of a shared tree based on some schema.

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 TreeView<in out TSchema extends ImplicitFieldSchema> extends IDisposable

Extends: IDisposable

Type Parameters

ParameterConstraintDescription
TSchemaImplicitFieldSchema

Remarks

This schema (known as the view schema) may or may not align with the stored schema of the document. Information about discrepancies between the two schemas is available via compatibility.

Application authors are encouraged to read schema-evolution.md and choose a schema compatibility policy that aligns with their application's needs.

Properties

PropertyModifiersTypeDescription
compatibilityreadonlySchemaCompatibilityStatus

Description of the current compatibility status between the view schema and stored schema.

schemaChanged() is fired when the compatibility status changes.

eventsreadonlyListenable<TreeViewEvents>Events for the tree.
rootTreeFieldFromImplicitField<TSchema>

The current root of the tree.

If the view schema not sufficiently compatible with the stored schema, accessing this will throw. To handle this case, check compatibility's canView before using.

To get notified about changes to this field, use rootChanged() via view.events.on("rootChanged", callback).

To get notified about changes to stored schema (which may affect compatibility between this view's schema and the stored schema), use schemaChanged() via view.events.on("schemaChanged", callback).

schemareadonlyTSchemaThe view schema used by this TreeView.

Methods

MethodReturn TypeDescription
initialize(content)void

Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.

Only valid to call when this view's canInitialize is true.

Applications should typically call this function before attaching a SharedTree.

upgradeSchema()voidWhen canUpgrade is true, this can be used to modify the stored schema to make it match the view schema.

Property Details

compatibility

Description of the current compatibility status between the view schema and stored schema.

schemaChanged() is fired when the compatibility status changes.

Signature

readonly compatibility: SchemaCompatibilityStatus;

Type: SchemaCompatibilityStatus

events

Events for the tree.

Signature

readonly events: Listenable<TreeViewEvents>;

Type: Listenable<TreeViewEvents>

root

The current root of the tree.

If the view schema not sufficiently compatible with the stored schema, accessing this will throw. To handle this case, check compatibility's canView before using.

To get notified about changes to this field, use rootChanged() via view.events.on("rootChanged", callback).

To get notified about changes to stored schema (which may affect compatibility between this view's schema and the stored schema), use schemaChanged() via view.events.on("schemaChanged", callback).

Signature

get root(): TreeFieldFromImplicitField<TSchema>;

set root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);

Type: TreeFieldFromImplicitField<TSchema>

schema

The view schema used by this TreeView.

Signature

readonly schema: TSchema;

Type: TSchema

Method Details

initialize

Initialize the tree, setting the stored schema to match this view's schema and setting the tree content.

Only valid to call when this view's canInitialize is true.

Applications should typically call this function before attaching a SharedTree.

Signature

initialize(content: InsertableTreeFieldFromImplicitField<TSchema>): void;

Parameters

ParameterTypeDescription
contentInsertableTreeFieldFromImplicitField<TSchema>The content to initialize the tree with.

upgradeSchema

When canUpgrade is true, this can be used to modify the stored schema to make it match the view schema.

Signature

upgradeSchema(): void;

Remarks

This will update the compatibility, allowing access to root. Beware that this may impact other clients' ability to view the document: see canView for more information.

It is an error to call this when canUpgrade is false. canUpgrade being true does not mean that an upgrade is required, nor that an upgrade will have any effect.

See Also

TreeViewAlpha

asTreeViewAlpha(view) \