TinyBase logoTinyBase β

WillSetValueCallback

The WillSetValueCallback type describes a function that is called before a Value is set in the Store.

(
  valueId: Id,
  value: Value,
): ValueOrUndefined
TypeDescription
valueIdId

The Id of the Value being set.

valueValue

The Value about to be set.

returnsValueOrUndefined

The Value to use (possibly transformed), or undefined to prevent the write.

The callback receives the value Id and the Value that is about to be set. It can return the Value (possibly transformed) to allow the write, or undefined to prevent the Value from being set.

Multiple WillSetValueCallback functions can be registered and they will be called sequentially, the Value being updated successively. If any callback returns undefined, the chain short-circuits and the Value will not be set.

Since

v8.0.0