Skip to main content

ImmutableValue class

📖 Description

The ImmutableValue class defines an immutable version of a Value instance. An ImmutableValue instance is obtained using the immutableValueOf method of a Context or using the immutable property of a Value.

🗃️ Fields


🏷️ context

Retrieves the context identifier for the value where * is the global (root) context.

Type

"*" | string


🏷️ hasValue

Retrieves if there is a value set.

Type

boolean


🏷️ isLocked

Retrieves if the value is locked (write-protected).

Type

boolean


🏷️ isModified

Retrieves if the value is modified.

Type

boolean


🏷️ isSealed

Retrieves if the value is sealed. A value is considered sealed when the form respondent has seen/answered the block and is past the section that contains the block that denotes this value. Only sealed values can be considered as confirmed by the form respondent. If a value is not sealed, it is not exportable.

Type

boolean


🏷️ key

Retrieves a unique key for the value within its context (the key is prefixed with an underscore).

Type

string


🏷️ reference

Retrieves the optional reference. This reference is used by some blocks to store an additional identifier related to the value. For example, when a value from a dropdown block is set, the reference is used to store the identifier of the selected item.

Type

string | undefined


🏷️ slot

Retrieves a reference to the slot that defines the value.

Type

Slot


🏷️ string

Retrieves the value as a string.

Type

string


🏷️ time

Retrieves the timestamp of the last value update as the number of milliseconds since the ECMAScript epoch.

Type

number | undefined


🏷️ value

Retrieves the typed value.

info

The type T is the value type denoted by the Slot type of the value.

Type

T

▶️ Methods


🔧 subscribe

Subscribe to value changes using the given context.

Signature

subscribe(fnChange: (value: Value) => void, context?: {}): this

Parameters

NameTypeOptionalDescription
fnChange(value: Value) => voidNoSpecifies the function that is invoked when the value is changed.
context{}YesSpecifies the context.

Return value

Returns a reference to the ImmutableValue instance.


🔧 unsubscribe

Unsubscribe the given context from the ImmutableValue instance.

Signature

unsubscribe(context?: {}): this

Parameters

NameTypeOptionalDescription
context{}YesSpecifies the context. If omitted all subscribers are unsubscribed.

Return value

Returns a reference to the ImmutableValue instance.