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
> Optimistic state management for Redux. No state copies, no checkpoints — optimistic state is derived at the selector level, like`git rebase`.
10
+
> Optimistic state management for Redux. Optimistic state is derived at the selector level by replaying transitions on top of committed state, similar to`git rebase`.
11
11
12
12
---
13
13
14
14
## Why Optimistron?
15
15
16
-
Most optimistic-update libraries snapshot your entire state tree for every in-flight operation. Optimistron doesn't. It tracks lightweight **transitions** (stage, amend, commit, fail) alongside your reducer state and replays them at read-time through `selectOptimistic` — right where `reselect` memoization already lives.
16
+
Optimistron tracks lightweight **transitions** (stage, amend, commit, fail) alongside your reducer state and replays them at read-time through `selectOptimistic`. No state snapshots or checkpoints are stored per operation.
17
17
18
-
Good fit for:
18
+
Optimistron was designed around an **event-driven saga architecture** — components dispatch intent via `stage`, and sagas (or listener middleware) orchestrate the transition lifecycle. It can be used with thunks or direct component dispatches, but the separation between intent and orchestration is where it fits most naturally.
19
19
20
-
-**Offline-first** — transitions queue up while disconnected, conflicts resolve on reconnect
-**Large/normalized state** — no per-operation snapshots
20
+
Designed for:
23
21
24
-
> Already happy with RTK Query's built-in optimistic updates? You probably don't need this.
22
+
-**Offline-first** — transitions queue up while disconnected, conflicts resolve on reconnect
23
+
-**Large/normalized state** — state is derived, not copied
25
24
26
25
---
27
26
@@ -38,7 +37,7 @@ Think of each `optimistron()` reducer as a **git branch**:
38
37
39
38
`STAGE`, `AMEND`, `FAIL`, `STASH` never touch reducer state — they only modify the transitions list. The optimistic view updates because `selectOptimistic` re-derives on the next read.
40
39
41
-
No `isLoading` / `error` / `isOptimistic` flags. A pending transition _is_loading. A failed one _is_ the error. One source of truth.
40
+
There are no separate `isLoading` / `error` / `isOptimistic` flags — a pending transition represents the loading state, and a failed transition carries the error.
subtitle: 'Component-level async — full transition lifecycle managed in the component.',
22
+
subtitle: 'Component-level async — the transition lifecycle is managed directly in the component.',
23
23
howItWorks: [
24
24
<>Component dispatches <O>stage</O>, awaits the API, then <O>amend</O>s / <C>commit</C>s or <F>fail</F>s directly.</>,
25
-
<>The full lifecycle (<O>stage</O> → API → <O>amend</O> → <C>commit</C> / <F>fail</F>) lives in the handler function — maximum visibility, minimum indirection.</>,
26
-
<>Optimistic state is computed at the selector level via <codeclassName="text-gray-400 text-[11px]">selectOptimistic</code> — no state copies, no checkpoints.</>,
25
+
<>The full lifecycle (<O>stage</O> → API → <O>amend</O> → <C>commit</C> / <F>fail</F>) lives in the handler function.</>,
26
+
<>Optimistic state is computed at the selector level via <codeclassName="text-gray-400 text-[11px]">selectOptimistic</code>.</>,
27
27
<>Failed transitions can be edited in-place — a new <O>stage</O> overwrites the failed one, restarting the lifecycle.</>,
subtitle: 'Redux sagas — the most decoupled approach.',
19
+
subtitle: 'Redux sagas — lifecycle orchestration decoupled from components.',
20
20
howItWorks: [
21
-
<>Component only dispatches <O>stage</O> — that's it. No async, no lifecycle awareness.</>,
21
+
<>Component only dispatches <O>stage</O>. No async logic or lifecycle management in the component.</>,
22
22
<>Saga watcher observes <O>stage</O> via <codeclassName="text-gray-400 text-[11px]">takeEvery</code> and orchestrates the full lifecycle to <C>commit</C> or <F>fail</F>.</>,
23
-
<>Maximum separation: UI fires intent, saga handles all orchestration — components are pure dispatch.</>,
0 commit comments