Execution — fw-01-mini-redux

Steps extracted from CONCEPTS.md. Read the concepts first; this file is the doing.

Record results in observation.md; tick checkpoints in verification.md.


3. Build order

  1. createStore(reducer)getState, dispatch, subscribe.
  2. combineReducers.
  3. Middleware + applyMiddleware.
  4. Enhancers — and articulate why these are a different extension point from middleware.
  5. Selectors with memoisation.
  6. Action/state recording.
  7. Time travel.
  8. Persistence.

Middleware to write: logger, timing, error handling, async.

Write each stage before reading the corresponding Redux source. The whole value is in the diff between your version and theirs.


4. Failure Lab — the bugs the real source defends against

Each of these is a real defence in Redux. Feel the bug first, then find the guard.

  1. Dispatch inside a reducer. What breaks, and why is a guard better than "don't do that"?
  2. Subscribe/unsubscribe during notification. Unsubscribe a listener from inside another listener while the notification loop is running. Watch a listener get skipped. This is why the real implementation snapshots the listener list — reproduce the skip, then fix it.
  3. Mutating state in a reducer with a memoised selector downstream. The selector's reference check says "unchanged," the UI goes stale. This is the strongest possible argument for immutability, and it is much more convincing after you have seen it.
  4. Middleware that dispatches synchronously in its own path. Find the re-entrancy.
  5. Getting state during dispatch. What consistency guarantee is at risk?