LiveStore:基于响应式SQLite和内置同步引擎的状态管理工具
LiveStore: State management based on reactive SQLite and built-in sync engine

原始链接: https://livestore.dev

导入事件和模式定义 ```javascript import { Events, Schema } from '@livestore/livestore'; // 事件定义 export const events = { todoCreated: Events.synced({ name: 'v1.TodoCreated', schema: Schema.Struct({ id: Schema.String, text: Schema.String, completed: Schema.Boolean.pipe(Schema.optional), }), }), todoCompleted: Events.synced({ name: 'v1.TodoCompleted', schema: Schema.Struct({ id: Schema.String, }), }), todoUncompleted: Events.synced({ name: 'v1.TodoUncompleted', schema: Schema.Struct({ id: Schema.String, }), }), todoDeleted: Events.synced({ name: 'v1.TodoDeleted', schema: Schema.Struct({ id: Schema.String, deletedAt: Schema.Date, }), }), }; ```

LiveStore, a new state management solution by the creator of Prisma, is in beta. It combines reactive SQLite with event-sourced syncing, similar to Git, for local-first applications. Designed for high-performance apps, like the music client Overtone, it addresses the need for robust sync engines. Users praise its neatness and elegance, comparing it favorably to alternatives like TinyBase. Questions arise around SQLite data limits (currently 1GB), multi-tenancy support, and the potential for a self-hosted sync server. The creator plans to address compaction of events in long-lived applications, and is considering user concerns around event-sourcing discipline. While cross-platform compatibility is a goal, Android web support is currently lacking due to shared worker limitations. The landing page emphasizes its relevance for collaborative applications such as Figma, Notion and Linear, although some users suggest this may not be the most effective marketing strategy. Overall, LiveStore is generating excitement for its potential in the local-first development space, especially with its use of WASM and SQLite.

原文
import { Events, Schema } from '@livestore/livestore'

// Definition of a events
export const events = {
  todoCreated: Events.synced({
    name: 'v1.TodoCreated',
    schema: Schema.Struct({ id: Schema.String, text: Schema.String, completed: Schema.Boolean.pipe(Schema.optional) }),
  }),
  todoCompleted: Events.synced({
    name: 'v1.TodoCompleted',
    schema: Schema.Struct({ id: Schema.String }),
  }),
  todoUncompleted: Events.synced({
    name: 'v1.TodoUncompleted',
    schema: Schema.Struct({ id: Schema.String }),
  }),
  todoDeleted: Events.synced({
    name: 'v1.TodoDeleted',
    schema: Schema.Struct({ id: Schema.String, deletedAt: Schema.Date }),
  }),
}
联系我们 contact @ memedata.com