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.
Type Parameters
Section titled “Type Parameters”TTo
Parameters
Section titled “Parameters”TTo
currentFacts
Section titled “currentFacts”Returns
Section titled “Returns”modify
Section titled “modify”modify:
object
modify.set
Section titled “modify.set”set:
Iterable<EventDefFactInput>
Facts to set (create or update).
modify.unset
Section titled “modify.unset”unset:
Iterable<EventDefFactInput>
Facts to unset (remove).
require
Section titled “require”require:
Iterable<EventDefFactInput>
Facts that must exist with specific values for this event to be valid.
Example
Section titled “Example”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'],})