You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/store-conventions.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,19 +6,19 @@ built on `@xstate/store`, with thin React adapters on top. This note records
6
6
when to reach for a store, where store code lives, and how it is tested.
7
7
8
8
Rule of thumb: **transition logic moves into store events; IO stays at the
9
-
boundary.** An effect that only *repairs state after render* is a store
9
+
boundary.** An effect that only _repairs state after render_ is a store
10
10
transition in disguise. An effect that talks to a renderer, timer, stream, or
11
11
process is doing its job.
12
12
13
13
## When to use what
14
14
15
-
| Situation | Use |
16
-
|---|---|
17
-
| Synchronous state updated by named events; cross-component; needs subscription/selectors (registry, surface stack, overlay stack, nav/search, sequence display) |`@xstate/store`|
18
-
| Async lifecycles with real states and cancellable work (content loader) |`@xstate/store` + request-ids first; full `xstate` only if a written justification shows the statechart pays for itself |
19
-
| Component-local input state that never crosses a component boundary (a filter query local to one overlay, a focus flag) | React `useState`|
20
-
| Purely derived render data |`useMemo`/selectors — never an effect, never a store |
21
-
| Imperative OpenTUI ref sync, subscriptions, timers, async IO | effects (or store-adjacent wrappers) — these are legitimate external synchronization and stay effects |
| Synchronous state updated by named events; cross-component; needs subscription/selectors (registry, surface stack, overlay stack, nav/search, sequence display) |`@xstate/store`|
18
+
| Async lifecycles with real states and cancellable work (content loader) |`@xstate/store` + request-ids first; full `xstate` only if a written justification shows the statechart pays for itself |
19
+
| Component-local input state that never crosses a component boundary (a filter query local to one overlay, a focus flag) | React `useState`|
20
+
| Purely derived render data |`useMemo`/selectors — never an effect, never a store|
21
+
| Imperative OpenTUI ref sync, subscriptions, timers, async IO | effects (or store-adjacent wrappers) — these are legitimate external synchronization and stay effects|
0 commit comments