Packages > @fluidframework/tree > TreeView
TreeView Interface
An editable view of a (version control style) branch of a shared tree.
This view is always in one of two states: 1. In schema: the stored schema is compatible with the provided view schema. There is no error, and root can be used. 2. Out of schema: the stored schema is incompatible with the provided view schema. There is an error, and root cannot be used.
Signature
export interface TreeView<TSchema extends ImplicitFieldSchema> extends IDisposable
Extends: IDisposable
Type Parameters
Parameter | Constraint | Description |
---|---|---|
TSchema | ImplicitFieldSchema |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
error |
optional , readonly
|
SchemaIncompatible |
Description of the error state, if any. When this is undefined, the view schema and stored schema are compatible, and root can be used.
|
events |
readonly
|
ISubscribable<TreeViewEvents> | Events for the tree. |
root | TreeFieldFromImplicitField<TSchema> |
The current root of the tree.
If in the out of schema state, accessing this will throw. To handle this case, check
To get notified about changes to this field (including to it being in an |
Methods
Method | Return Type | Description |
---|---|---|
upgradeSchema() | void |
When there is an error and canUpgrade is true, this can be used to modify the stored schema to make it match the view schema. This will clear the error state, and allow access to root .
|
Property Details
error
Description of the error state, if any. When this is undefined, the view schema and stored schema are compatible, and root
can be used.
Signature
readonly error?: SchemaIncompatible;
events
Events for the tree.
Signature
readonly events: ISubscribable<TreeViewEvents>;
root
The current root of the tree.
If in the out of schema state, accessing this will throw. To handle this case, check error
before using.
To get notified about changes to this field (including to it being in an error
state), use rootChanged()
via view.events.on("rootChanged", callback)
.
Signature
get root(): TreeFieldFromImplicitField<TSchema>;
set root(newRoot: InsertableTreeFieldFromImplicitField<TSchema>);
Method Details
upgradeSchema
When there is an error
and canUpgrade
is true, this can be used to modify the stored schema to make it match the view schema. This will clear the error state, and allow access to root
.
Signature
upgradeSchema(): void;
Remarks
It is an error to call this when canUpgrade
is false, and a no-op when not in an error
state. When this changes the stored schema, any existing or future clients which were compatible with the old stored schema will get an error
state when trying to schematize the document.