StoreAfterCreateHandler

See source code

Handler function called after a record has been successfully created in the store. Use this for side effects that should happen after record creation, such as updating related records or triggering notifications.

type StoreAfterCreateHandler<R extends UnknownRecord> = (
  record: R,
  source: "remote" | "user",
) => void;

Example

const handler: StoreAfterCreateHandler<BookRecord> = (book, source) => {
  if (source === "user") {
    console.log(`New book added: ${book.title}`);
    updateAuthorBookCount(book.authorId);
  }
};

Parameters

NameDescription

record

The record that was created

source

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

Prev
StoreAfterChangeHandler
Next
StoreAfterDeleteHandler