StoreBeforeDeleteHandler

See source code

Handler function called before a record is deleted from the store. The handler can return false to prevent the deletion from occurring.

type StoreBeforeDeleteHandler<R extends UnknownRecord> = (
  record: R,
  source: 'remote' | 'user'
) => false | void

Example

const handler: StoreBeforeDeleteHandler<BookRecord> = (book, source) => {
  // Prevent deletion of books that are currently checked out
  if (book.isCheckedOut) {
    console.warn('Cannot delete checked out book')
    return false
  }
  // Allow deletion for other books
}

Parameters

NameDescription

record

The record about to be deleted

source

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

Prev
StoreBeforeCreateHandler
Next
StoreListener