TinyBase logoTinyBase

ValueListener

The ValueListener type describes a function that is used to listen to changes to a Value.

(
  store: Store,
  valueId: Id,
  newValue: Value,
  oldValue: Value,
  getValueChange: GetValueChange | undefined,
): void
TypeDescription
storeStore

A reference to the Store that changed.

valueIdId

The Id of the Value that changed.

newValueValue

The new value of the Value that changed.

oldValueValue

The old value of the Value that changed.

getValueChangeGetValueChange | undefined

A function that returns information about any Value's changes.

returnsvoid

This has no return value.

A ValueListener is provided when using the addValueListener method. See that method for specific examples.

When called, a ValueListener is given a reference to the Store and the Id of Value that changed. It is also given the new value of the Value, the old value of the Value, and a GetValueChange function that can be used to query Values before and after the current transaction.

Note that if the listener was manually forced to be called (with the callListener method rather than due to a real change in the Store), the GetValueChange function will not be present and the new and old values of the Value will be the same.

Since

v3.0.0