Redux dispatch synchronous guarantee
0 reputation · 14 Jun 2021, 07:25 UTC
Goal: Determine the exact point in the Redux cycle at which store subscribers are notified relative to middleware next() execution when an action originates from an asynchronous thunk.
Constraint: The official Redux core describes dispatch as synchronous, yet redux-thunk and similar middleware commonly defer state updates through nested dispatches, creating ambiguity about whether intermediate states become observable before the middleware chain fully resolves. The documented behavior does not specify the notification order for subscribers when middleware intercepts and re-dispatches actions within the same cycle.
Questions:
- Does the Redux store notify subscribers before or after middleware
next()completes its internal dispatch sequence? - When a thunk dispatches two actions consecutively, are both intermediate states visible to subscribers synchronously after each dispatch call?
- What does
replaceReducerdo to the synchronous dispatch contract for listeners attached prior to the replacement?