Jotai Reactive Atoms

Implement reactive state management with Jotai atoms in Electron renderer. Use when creating atoms with real-time IPC updates or hybrid stream + HTTP patterns.

naporin0624 Updated

File contents

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

  1. Hybrid atom getter must NOT be async - use sync conditional
  2. Always debounce IPC handlers - prevent UI thrashing
  3. 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

naporin0624/claude-plugin-hono-electron/tree/main/skills/jotai-reactive-atoms commit 7c682b55c2

Frequently asked questions

npx skillmds@latest add naporin0624/jotai-reactive-atoms