# Behavior traces — reduxjs/redux

> Canonical page: https://codevetter.com/unpack/redux/behavior-traces

# Behavior traces — reduxjs/redux

Scanned commit 56abca4749921d68f40cda20afd2043af9751f72 (2026-09-29). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

The traced flows cover core startup, browser interaction, middleware construction, async counter behavior, reducer replacement, observable delivery, checkout, and documentation acquisition. These walkthroughs follow source execution order and preserve the important conditional branches. They describe expected behavior from code inspection, without asserting successful runtime execution.
- Core startup: createStore validates reducer → normalizes an enhancer passed as argument two → delegates through enhancer(createStore) when supplied; otherwise it allocates state/listeners → dispatches INIT → returns the store. — [src/createStore.ts#L97-L143](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/src/createStore.ts#L97-L143) [src/createStore.ts#L382-L394](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/src/createStore.ts#L382-L394)
- Vanilla counter: module import → createStore(counter) → render → subscribe(render); an increment click dispatches INCREMENT → counter returns state + 1 → dispatch invokes render → getState().toString() updates the DOM. — [examples/counter-vanilla/index.html#L17-L48](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/examples/counter-vanilla/index.html#L17-L48) [src/createStore.ts#L297-L308](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/src/createStore.ts#L297-L308)
- Middleware setup: applyMiddleware(...)(createStore) creates the base store → installs a throwing temporary dispatch → calls each middleware with middlewareAPI → composes wrappers around store.dispatch → returns the copied store with enhanced dispatch. — [src/applyMiddleware.ts#L53-L76](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/src/applyMiddleware.ts#L53-L76) [src/compose.ts#L46-L60](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/src/compose.ts#L46-L60)
- Toolkit counter: index.tsx renders Provider(store) and App → App renders Counter → Add Async dispatches incrementAsync(amount) → pending sets loading → fetchCount resolves after 500ms → fulfilled sets idle and adds the payload; rejected sets failed. — [examples/counter-ts/src/index.tsx#L9-L18](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/examples/counter-ts/src/index.tsx#L9-L18) [examples/counter-ts/src/App.tsx#L5-L14](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/examples/counter-ts/src/App.tsx#L5-L14) [examples/counter-ts/src/features/counter/Counter.tsx#L53-L57](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/examples/counter-ts/src/features/counter/Counter.tsx#L53-L57) [examples/counter-ts/src/features/counter/counterSlice.ts#L20-L62](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/examples/counter-ts/src/features/counter/counterSlice.ts#L20-L62)
- Reducer replacement: replaceReducer validates nextReducer → assigns currentReducer → dispatches REPLACE; combination reuses existing slices, initializes newly undefined slices, and drops keys absent from its new reducer map. — [src/createStore.ts#L320-L335](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/src/createStore.ts#L320-L335) [src/combineReducers.ts#L157-L199](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/src/combineReducers.ts#L157-L199) [test/combineReducers.spec.ts#L311-L382](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/test/combineReducers.spec.ts#L311-L382)
- Observable subscription: store's observable method returns a subscribable object → subscribe validates observer → observeState immediately calls next(getState()) when next exists → registers observeState through store.subscribe → returns its unsubscribe handle. — [src/createStore.ts#L344-L378](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/src/createStore.ts#L344-L378) [src/utils/symbol-observable.ts#L7-L10](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/src/utils/symbol-observable.ts#L7-L10)
- Checkout: checkout(products) snapshots getState().cart → dispatches CHECKOUT_REQUEST, resetting cart → shop.buyProducts invokes its timed callback → CHECKOUT_SUCCESS is dispatched with the saved cart; rollback is an explicitly commented alternative CHECKOUT_FAILURE path. — [examples/shopping-cart/src/actions/index.js#L26-L39](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/examples/shopping-cart/src/actions/index.js#L26-L39) [examples/shopping-cart/src/api/shop.js#L6-L12](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/examples/shopping-cart/src/api/shop.js#L6-L12) [examples/shopping-cart/src/reducers/cart.js#L39-L49](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/examples/shopping-cart/src/reducers/cart.js#L39-L49)
- Docs acquisition: parse flags and requested library names → reject unknown names → skip existing targets unless forced or locally sourced → copyLocalSource or cloneSource → optionally watch local files and spawn pnpm start; clone failures remove partial targets and retry once. — [website/scripts/fetch-external-docs.mts#L83-L98](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/website/scripts/fetch-external-docs.mts#L83-L98) [website/scripts/fetch-external-docs.mts#L118-L151](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/website/scripts/fetch-external-docs.mts#L118-L151) [website/scripts/fetch-external-docs.mts#L190-L225](https://github.com/reduxjs/redux/blob/56abca4749921d68f40cda20afd2043af9751f72/website/scripts/fetch-external-docs.mts#L190-L225)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
