Skip to content

reducer builder: track call order using Set, to allow differentiating between addAsyncThunk and addMatcher#5071

Open
EskiMojo14 wants to merge 5 commits into
masterfrom
call-order
Open

reducer builder: track call order using Set, to allow differentiating between addAsyncThunk and addMatcher#5071
EskiMojo14 wants to merge 5 commits into
masterfrom
call-order

Conversation

@EskiMojo14

@EskiMojo14 EskiMojo14 commented Sep 4, 2025

Copy link
Copy Markdown
Collaborator

This properly enforces that addAsyncThunk is called before addMatcher, which was previously only enforced in types.

It also consolidates a bit of missing logic - it was previously possible to silently override an addCase with addAsyncThunk:

builder
  .addCase(thunk.pending, reducer1)
  .addAsyncThunk(thunk, { pending: reducer2 }) // reducer1 is never called, this silently overrides it

this now correctly throws an error.

@codesandbox

codesandbox Bot commented Sep 4, 2025

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@codesandbox-ci

codesandbox-ci Bot commented Sep 4, 2025

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 097bf87:

Sandbox Source
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration
rtk-esm-cra Configuration

@github-actions

github-actions Bot commented Sep 4, 2025

Copy link
Copy Markdown

size-limit report 📦

Path Size
1. entry point: @reduxjs/toolkit/query (browser.mjs) 6.4 KB (+0.25% 🔺)
1. entry point: @reduxjs/toolkit/query/react (modern.mjs) 16.06 KB (+0.02% 🔺)
1. entry point: @reduxjs/toolkit/query/react (browser.mjs) 19.11 KB (+0.32% 🔺)
3. createSlice (.modern.mjs) 4.71 KB (+0.11% 🔺)
3. buildCreateSlice and asyncThunkCreator (.modern.mjs) 5.61 KB (+0.13% 🔺)
3. createApi (.modern.mjs) 16.48 KB (+0.03% 🔺)
3. createApi (react) (.modern.mjs) 18.54 KB (-0.08% 🔽)

@netlify

netlify Bot commented Sep 4, 2025

Copy link
Copy Markdown

Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit 850cf9d
🔍 Latest deploy log https://app.netlify.com/projects/redux-starter-kit-docs/deploys/6a4d09824fdde70008e6ba60
😎 Deploy Preview https://deploy-preview-5071--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@aryaemami59 aryaemami59 changed the title reducer builder: track call order using Set, to allow differentiating between addAsyncThunk and addMatcher reducer builder: track call order using Set, to allow differentiating between addAsyncThunk and addMatcher Mar 18, 2026
@aryaemami59 aryaemami59 added RTK-Query Issues related to Redux-Toolkit-Query Needs Feedback More input is needed before moving forward. labels Mar 18, 2026
@aryaemami59 aryaemami59 added this to the 3.0 milestone Mar 18, 2026
Comment thread packages/toolkit/src/mapBuilders.ts
Comment thread packages/toolkit/src/tests/createReducer.test.ts Outdated
Comment thread errors.json
@pkg-pr-new

pkg-pr-new Bot commented Jul 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

@reduxjs/rtk-codemods

npm i https://pkg.pr.new/@reduxjs/rtk-codemods@850cf9d -D
yarn add https://pkg.pr.new/@reduxjs/rtk-codemods@850cf9d.tgz -D
pnpm add https://pkg.pr.new/@reduxjs/rtk-codemods@850cf9d.tgz -D
bun add https://pkg.pr.new/@reduxjs/rtk-codemods@850cf9d.tgz -D

@rtk-query/codegen-openapi

npm i https://pkg.pr.new/@rtk-query/codegen-openapi@850cf9d -D
yarn add https://pkg.pr.new/@rtk-query/codegen-openapi@850cf9d.tgz -D
pnpm add https://pkg.pr.new/@rtk-query/codegen-openapi@850cf9d.tgz -D
bun add https://pkg.pr.new/@rtk-query/codegen-openapi@850cf9d.tgz -D

@rtk-query/graphql-request-base-query

npm i https://pkg.pr.new/@rtk-query/graphql-request-base-query@850cf9d -D
yarn add https://pkg.pr.new/@rtk-query/graphql-request-base-query@850cf9d.tgz -D
pnpm add https://pkg.pr.new/@rtk-query/graphql-request-base-query@850cf9d.tgz -D
bun add https://pkg.pr.new/@rtk-query/graphql-request-base-query@850cf9d.tgz -D

@reduxjs/toolkit

npm i https://pkg.pr.new/@reduxjs/toolkit@850cf9d -D
yarn add https://pkg.pr.new/@reduxjs/toolkit@850cf9d.tgz -D
pnpm add https://pkg.pr.new/@reduxjs/toolkit@850cf9d.tgz -D
bun add https://pkg.pr.new/@reduxjs/toolkit@850cf9d.tgz -D

commit: 850cf9d

@EskiMojo14 EskiMojo14 removed the RTK-Query Issues related to Redux-Toolkit-Query label Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Feedback More input is needed before moving forward.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants