Skip to content

defineFacts

const defineFacts: <TRecord>(record) => TRecord

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

Helper to define a typed record of fact constructors. Returns the input unchanged but provides type inference.

TRecord extends Record<string, EventDefFactInput | (…args) => EventDefFactInput>

TRecord

TRecord

const facts = defineFacts({
// Simple fact (value = true)
initialized: 'system:initialized',
// Parameterized fact constructor
todoExists: (id: string) => [`todo:${id}`, true] as const,
// Fact with complex value
todoStatus: (id: string, status: string) => [`todo:${id}:status`, status] as const,
})
// Usage
facts.todoExists('abc') // => ['todo:abc', true]