> For a complete documentation index, fetch https://docs.voximplant.ai/llms.txt

# ReadonlyWatchable (interface)

[Watchable](/api-reference/websdk5/core/watchable/overview)

Basic WebSDK reactive type for immutable structures and primitives, the same as [Watchable](/api-reference/websdk5/core/watchable/overview), but with readonly values.
Setting a new value is ignored without any error, with only a warn message in the console.

**Methods**

* [clear](/api-reference/websdk5/core/watchable/readonlywatchable#clear)
* [reset](/api-reference/websdk5/core/watchable/readonlywatchable#reset)
* [unwatch](/api-reference/websdk5/core/watchable/readonlywatchable#unwatch)
* [watch](/api-reference/websdk5/core/watchable/readonlywatchable#watch)

**Properties**

* [oldValue](/api-reference/websdk5/core/watchable/readonlywatchable#oldvalue)
* [value](/api-reference/websdk5/core/watchable/readonlywatchable#value)

## Methods

### clear

`clear(): void`

Clears all observers for this watchable excluding the ones created with [WatchOptions.clearable](/api-reference/websdk5/core/watchable/watchoptions#clearable): false.

**Returns:** void

### reset

`reset(value?: T): void`

Sets both [Watchable.value](/api-reference/websdk5/core/watchable/watchable#value) and [Watchable.oldValue](/api-reference/websdk5/core/watchable/watchable#oldvalue) to the given or initial value.

The [Watchable.watch](/api-reference/websdk5/core/watchable/watchable#watch) callback is triggered only when the reset value differs from the current [Watchable.value](/api-reference/websdk5/core/watchable/watchable#value).
It receives the previous content as its second argument, but [Watchable.oldValue](/api-reference/websdk5/core/watchable/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**

| Parameter | Type | Requirement | Description                                                                                                     |
| --------- | ---- | ----------- | --------------------------------------------------------------------------------------------------------------- |
| `value`   | `T`  | Optional    | Value to reset to. Defaults to the value the watchable was created with or to the value used in the last reset. |

**Returns:** void

### unwatch

`unwatch(onValueChangeCallback: `[`OnValueChangeCallback`](/api-reference/websdk5/core/watchable/onvaluechangecallback)`): void`

Stops triggering the specified callback on the value change.

**Parameters**

| Parameter               | Type                                                                                   | Requirement | Description                                   |
| ----------------------- | -------------------------------------------------------------------------------------- | ----------- | --------------------------------------------- |
| `onValueChangeCallback` | [`OnValueChangeCallback`](/api-reference/websdk5/core/watchable/onvaluechangecallback) | Required    | Observer that should not be triggered anymore |

**Returns:** void

### watch

`watch(onValueChangeCallback: `[`OnValueChangeCallback`](/api-reference/websdk5/core/watchable/onvaluechangecallback)`, options?: `[`WatchOptions`](/api-reference/websdk5/core/watchable/watchoptions)`): `[`UnwatchFunction`](/api-reference/websdk5/core/watchable/unwatchfunction)

Subscribes to the value changes.

When the value is changed, the [OnValueChangeCallback](/api-reference/websdk5/core/watchable/onvaluechangecallback) callback is triggered.

Returns [UnwatchFunction](/api-reference/websdk5/core/watchable/unwatchfunction), to unwatch observable value changes.

**Parameters**

| Parameter               | Type                                                                                   | Requirement | Description                                        |
| ----------------------- | -------------------------------------------------------------------------------------- | ----------- | -------------------------------------------------- |
| `onValueChangeCallback` | [`OnValueChangeCallback`](/api-reference/websdk5/core/watchable/onvaluechangecallback) | Required    | Observer to be triggered when the value is changed |
| `options`               | [`WatchOptions`](/api-reference/websdk5/core/watchable/watchoptions)                   | Optional    | Options                                            |

**Returns:** [UnwatchFunction](/api-reference/websdk5/core/watchable/unwatchfunction)

## Properties

### oldValue

`oldValue: T`

Previous value of the observable property.

### value

`value: T`

Current value of the observable property.