ReadonlyWatchable (interface)
Basic WebSDK reactive type for immutable structures and primitives, the same as Watchable, but with readonly values. Setting a new value is ignored without any error, with only a warn message in the console.
Methods
clear
clear(): void
Clears all observers for this watchable excluding the ones created with WatchOptions.clearable: false.
Returns: void
reset
reset(value?: T): void
Sets both Watchable.value and Watchable.oldValue to the given or initial value.
The Watchable.watch callback is triggered only when the reset value differs from the current Watchable.value. It receives the previous content as its second argument, but Watchable.oldValue is already reset.
Does not remove watchers.
Note: Teardown is a common use case, since assigning
null
is not enough - the watchable holds a reference to the previous value.
Since: 5.4.0
Parameters
Returns: void
unwatch
unwatch(onValueChangeCallback: OnValueChangeCallback): void
Stops triggering the specified callback on the value change.
Parameters
Returns: void
watch
watch(onValueChangeCallback: OnValueChangeCallback, options?: WatchOptions): UnwatchFunction
Subscribes to the value changes.
When the value is changed, the OnValueChangeCallback callback is triggered.
Returns UnwatchFunction, to unwatch observable value changes.
Parameters
Returns: UnwatchFunction
Properties
oldValue
oldValue: T
Previous value of the observable property.
value
value: T
Current value of the observable property.