synced
constsynced: <TName,TType,TEncoded>(args) =>EventDef<TName,TType,TEncoded>
Defined in: packages/@livestore/common/dist/schema/EventDef/define.d.ts:112
Creates a synced event definition.
Synced events are sent to the sync backend and distributed to all connected clients. Use this for collaborative data that should be shared across users and devices.
Event names should be versioned (e.g., v1.TodoCreated) to support
schema evolution over time.
Type Parameters
Section titled “Type Parameters”TName extends string
TType
TEncoded
Section titled “TEncoded”TEncoded = TType
Parameters
Section titled “Parameters”object & Omit<DefineEventOptions<TType, false>, "derived" | "clientOnly">
Returns
Section titled “Returns”EventDef<TName, TType, TEncoded>
Example
Section titled “Example”import { Events } from '@livestore/livestore'import { Schema } from 'effect'
const todoCreated = Events.synced({ name: 'v1.TodoCreated', schema: Schema.Struct({ id: Schema.String, text: Schema.String, completed: Schema.Boolean, }),})
// Commit the eventstore.commit(todoCreated({ id: 'abc', text: 'Buy milk', completed: false }))