StoreAfterChangeHandler

See source code

Handler function called after a record has been successfully updated in the store. Use this for side effects that should happen after record changes, such as updating related records or maintaining consistency constraints.

type StoreAfterChangeHandler<R extends UnknownRecord> = (
  prev: R,
  next: R,
  source: 'remote' | 'user'
) => void

Example

const handler: StoreAfterChangeHandler<ShapeRecord> = (prev, next, source) => {
  // Update connected arrows when a shape moves
  if (prev.x !== next.x || prev.y !== next.y) {
    updateConnectedArrows(next.id)
  }
}

Parameters

NameDescription

prev

The previous version of the record

next

The new version of the record that was stored

source

Whether the change originated from 'user' interaction or 'remote' synchronization

Prev
SerializedStore
Next
StoreAfterCreateHandler