name: jotai-reactive-atoms
description: Implement reactive state management with Jotai atoms in Electron renderer. Use when creating atoms with real-time IPC updates or hybrid stream + HTTP patterns.
allowed-tools: Read, Write, Edit, Grep, Glob
Jotai Reactive Atoms
Patterns
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
// Hybrid selector (sync, NOT async)
export const usersAtom = atom((get) => {
const stream = get(streamAtom);
return stream !== undefined ? stream.value : get(singleFetchAtom);
});
Related