Middleware
May intercept the dispatch path.
next(action) decides what reaches the reducer.
Original action: not dispatched
Central store
0 uploads{ "uploads": [] }
No pending work.
Actions reaching the reducer
0- No actions yet.
An architectural case study About one minute
Keep the side-effects. Remove the power to intercept actions.
Middleware can watch state, too. The architectural change is what an engine cannot do: delay, rename, or swallow an action on its way to the reducer. It watches committed state and can dispatch new actions, each through the same direct path.
The experiment
architecture.pdf
Try both. Middleware can behave like an engine; its interface still permits interception.
Both dispatch UPLOAD_QUEUED with the same file and scheduled start.
Queue an upload and compare the original action’s receipt. Then try the other middleware behavior.
May intercept the dispatch path.
next(action) decides what reaches the reducer.
Original action: not dispatched
{ "uploads": [] }
No pending work.
No interception point in its interface.
read · subscribe · dispatch — no next.
Original action: not dispatched
{ "uploads": [] }
No pending work.
This compact status bar reads each store independently. No upload-specific wiring to either widget.
A deterministic simulation: both paths share the same transfer implementation and two-tick delay. No file is uploaded. Each visitor gets an independent run; reset or refresh starts over.
What I would change
Giving side-effect code control over dispatch meant an action could be delayed, renamed, or swallowed before the reducer saw it. Tracing a name was no longer enough.
Remove the interception interface. Dispatch goes straight to the reducer. Engines observe committed state and dispatch separate actions to report their work.
Side-effects stay flexible: timers, uploads, retries, and result actions. Pending intent and progress can live in shared state, while the original action remains traceable.
These are the running functions, displayed from the module itself. The middleware chain receives next and the action. The engine receives only state access, subscription, and dispatch. Its dispatch is the store’s own function; an observer cannot replace or withhold the action it is reacting to.