TreeViewConfiguration Class

Packages > @fluidframework/tree > TreeViewConfiguration

Configuration for viewWith(config) .

Signature

/** @sealed */
export declare class TreeViewConfiguration<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> implements Required<ITreeViewConfiguration<TSchema>>

Implements: Required<ITreeViewConfiguration <TSchema>>

Type Parameters

Parameter Constraint Default Description
TSchema ImplicitFieldSchema ImplicitFieldSchema

Constructors

Constructor Description
(constructor)(props) Constructs a new instance of the TreeViewConfiguration class

Properties

Property Modifiers Type Description
_typeCheck MakeNominal
enableSchemaValidation readonly boolean If true, the tree will validate new content against its stored schema at insertion time and throw an error if the new content doesn't match the expected schema.
preventAmbiguity readonly boolean A flag used to opt into strict rules ensuring that the schema avoids cases which can make the type of nodes ambiguous when importing or exporting data.
schema readonly TSchema The schema which the application wants to view the tree with.

Constructor Details

(constructor)

Constructs a new instance of the TreeViewConfiguration class

Signature

constructor(props: ITreeViewConfiguration<TSchema>);

Parameters

Parameter Type Description
props ITreeViewConfiguration<TSchema> Property bag of configuration options.

Property Details

_typeCheck

Signature

protected _typeCheck: MakeNominal;

Type: MakeNominal

enableSchemaValidation

If true, the tree will validate new content against its stored schema at insertion time and throw an error if the new content doesn’t match the expected schema.

Signature

readonly enableSchemaValidation: boolean;

Type: boolean

Remarks

Enabling schema validation has a performance penalty when inserting new content into the tree because additional checks are done. Enable this option only in scenarios where you are ok with that operation being a bit slower.

preventAmbiguity

A flag used to opt into strict rules ensuring that the schema avoids cases which can make the type of nodes ambiguous when importing or exporting data.

Signature

readonly preventAmbiguity: boolean;

Type: boolean

Remarks

When this is true, it ensures that the compile time type safety for data when constructing nodes is sufficient to ensure that the runtime behavior will not give node data ambiguity errors.

This ensures that the canonical JSON-like representation of all unions in the tree are lossless and unambiguous. This canonical JSON-like representation consists of arrays, plain old JavaScript objects with string keys, booleans, numbers (excluding NaN, -0 and infinities), strings, null and _@fluidframework/core-interfaces#IFluidHandle_s. It is compatible with the node creation APIs (such as schema class constructors) and is also compatible with JSON assuming any IFluidHandles get special handling (since they are not JSON compatible). Currently these cases can cause ambiguity in a union:

  • More than one ArrayNode type: it’s impossible to tell which array type is intended in the case of empty arrays ([]).

  • More than one MapNode type: it’s impossible to tell which map type is intended in the case of an empty map ({}).

  • Both a MapNode and an ArrayNode: this case is not a problem for the canonical JSON representation, but is an issue when constructing from an Iterable, which is supported for both MapNode and ArrayNode.

  • Both a MapNode and an ObjectNode: when the input is valid for the ObjectNode, the current parser always considers it ambiguous with being a MapNode.

  • ObjectNodes which have fields (required or optional) which include all required fields of another ObjectNode: currently each ObjectNode is differentiated by the presence of its required fields.

This check is conservative: some complex cases may error if the current simple algorithm cannot show no ambiguity is possible. This check may become more permissive over time.

schema

The schema which the application wants to view the tree with.

Signature

readonly schema: TSchema;

Type: TSchema