There is currently no way to react to record lifecycle events. Apps can't observe when records are created, updated, or deleted without polling.
This matters for several use cases:
- Full-text or secondary indexing — rebuild an index when a record changes
- Sync — propagate local writes to a remote when the
adapter-api lands
- Audit logging — record who changed what and when
- Reactive UI — invalidate caches or trigger re-renders on write
Proposed API (sketch):
stack.on('record:create', (record) => { ... });
stack.on('record:update', (record, previous) => { ... });
stack.on('record:delete', (id, { hard }) => { ... });
// or filtered by type:
stack.on('record:update', { typeId: 'com.example.app/note@1' }, (record) => { ... });
Hooks could be synchronous (fire-and-forget) or async (awaited before the write completes — useful for indexing). The right model needs thought, especially around error handling if a hook throws.
The adapter interface may also need a hook mechanism so that adapters (particularly adapter-api) can emit events from remote changes, not just local writes.
There is currently no way to react to record lifecycle events. Apps can't observe when records are created, updated, or deleted without polling.
This matters for several use cases:
adapter-apilandsProposed API (sketch):
Hooks could be synchronous (fire-and-forget) or async (awaited before the write completes — useful for indexing). The right model needs thought, especially around error handling if a hook throws.
The adapter interface may also need a hook mechanism so that adapters (particularly
adapter-api) can emit events from remote changes, not just local writes.