TinyBase logoTinyBase

TransactionListener

The TransactionListener type describes a function that is used to listen to the completion of a transaction for the Store.

(
  store: Store,
  cellsTouched: boolean,
  valuesTouched: boolean,
): void
TypeDescription
storeStore

A reference to the Store that is completing a transaction.

cellsTouchedboolean

Whether Cell values have been touched during the transaction.

valuesTouchedboolean

Whether Values have been touched during the transaction, since v3.0.0.

returnsvoid

This has no return value.

A TransactionListener is provided when using the addWillFinishTransactionListener and addDidFinishTransactionListener methods. See those methods for specific examples.

When called, a TransactionListener is simply given a reference to the Store and booleans to indicate whether Cell or Value data has been touched during the transaction. The two flags are intended as a hint about whether non-mutating listeners might be being called at the end of the transaction.

Here, 'touched' means that Cell or Value data has either been changed, or changed and then changed back to its original value during the transaction. The exception is a transaction that has been rolled back, for which the value of cellsTouched and valuesTouched in the listener will be false because all changes have been reverted.