Skip to main content

Class: TemplateState

Defined in: data/schema.ts:46

Contains a state with typed values for any defined template properties.

Each property value should be JSON-serializable to be able to export and import it as part of the serialized diagram layout.

Constructors

Constructor

new TemplateState(value): TemplateState

Defined in: data/schema.ts:49

Parameters

ParameterType

value

undefined | {[property: string]: unknown; }

Returns

TemplateState

Properties

PropertyModifierType

empty

static

TemplateState

Methods

get()

get<V>(property): undefined | V

Defined in: data/schema.ts:71

Gets typed template property value from a template state.

Type Parameters

Type Parameter

V

Parameters

ParameterType

property

TemplateProperty<string, V>

Returns

undefined | V


set()

set<V>(property, value): TemplateState

Defined in: data/schema.ts:86

Sets optional typed template property value on a template state.

This function never mutates the original state and always return either original state (if the property value is the same) or newly created updated state.

If the value is undefined, the property will be removed from the state, otherwise the new value will be set.

Type Parameters

Type Parameter

V

Parameters

ParameterType

property

TemplateProperty<string, V>

value

V

Returns

TemplateState


toJSON()

toJSON(): undefined | SerializedTemplateState

Defined in: data/schema.ts:105

Returns

undefined | SerializedTemplateState


fromJSON()

static fromJSON(value): TemplateState

Defined in: data/schema.ts:99

Parameters

ParameterType

value

undefined | {[property: string]: unknown; }

Returns

TemplateState


property()

static property<K>(key): object

Defined in: data/schema.ts:61

Utility function to define typed template property.

Example:

const MyNumberProperty = TemplateState.property('urn:my:prop1').of<number>();

Type Parameters

Type Parameter

K extends string

Parameters

ParameterType

key

K

Returns

object

of()

of<V>(): TemplateProperty<K, V>

Type Parameters
Type Parameter

V

Returns

TemplateProperty<K, V>