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
| Parameter | Type |
|---|---|
|
|
Returns
TemplateState
Properties
| Property | Modifier | Type |
|---|---|---|
|
|
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 |
|---|
|
Parameters
| Parameter | Type |
|---|---|
|
|
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 |
|---|
|
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
Returns
TemplateState
toJSON()
toJSON():
undefined|SerializedTemplateState
Defined in: data/schema.ts:105
Returns
undefined | SerializedTemplateState
fromJSON()
staticfromJSON(value):TemplateState
Defined in: data/schema.ts:99
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
TemplateState
property()
staticproperty<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 |
|---|
|
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
object
of()
of<
V>():TemplateProperty<K,V>
Type Parameters
| Type Parameter |
|---|
|
Returns
TemplateProperty<K, V>