Skip to content

FactsCallback

FactsCallback<TTo> = (args, currentFacts) => object

Defined in: packages/@livestore/common/dist/schema/EventDef/facts.d.ts:86

Callback function that defines how an event interacts with the facts system. Called during event processing to determine fact constraints.

TTo

TTo

EventDefFacts

modify: object

set: Iterable<EventDefFactInput>

Facts to set (create or update).

unset: Iterable<EventDefFactInput>

Facts to unset (remove).

require: Iterable<EventDefFactInput>

Facts that must exist with specific values for this event to be valid.

const factsCallback: FactsCallback<{ id: string }> = (args, currentFacts) => ({
modify: {
set: [`item:${args.id}`], // Create/update this fact
unset: [], // No facts to remove
},
require: currentFacts.has('initialized') ? [] : ['initialized'],
})