Jotai Reactive Atoms
Patterns
| Pattern | Use Case | Details |
|---|---|---|
| Hybrid Atom | Real-time + HTTP fallback | HYBRID-ATOM.md |
| Stream Atom | IPC subscriptions | EVENT-SUBSCRIPTION.md |
| Write Atom | CRUD mutations | WRITE-ATOM.md |
Key Rules
- •Hybrid atom getter must NOT be async - use sync conditional
- •Always debounce IPC handlers - prevent UI thrashing
- •Refresh read atoms after mutations -
set(singleFetchAtom)
Quick Example
typescript
// Hybrid selector (sync, NOT async)
export const usersAtom = atom((get) => {
const stream = get(streamAtom);
return stream !== undefined ? stream.value : get(singleFetchAtom);
});
Related
- •suspense-boundary-design - Suspense and ErrorBoundary