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 (browser.mjs) 5.54 KB (-0.3% 🔽)
1. entry point: @reduxjs/toolkit/query (browser.mjs) 6.39 KB (+0.3% 🔺)
1. entry point: @reduxjs/toolkit/query/react (modern.mjs) 16.06 KB (-0.01% 🔽)
1. entry point: @reduxjs/toolkit/query/react (browser.mjs) 19.1 KB (+0.07% 🔺)
3. createSlice (.modern.mjs) 4.71 KB (+0.11% 🔺)
3. buildCreateSlice and asyncThunkCreator (.modern.mjs) 5.59 KB (+0.11% 🔺)
3. createApi (.modern.mjs) 16.46 KB (+0.1% 🔺)
3. createApi (react) (.modern.mjs) 18.56 KB (+0.33% 🔺)

@netlify

netlify Bot commented Sep 4, 2025

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit d2792f3
🔍 Latest deploy log https://app.netlify.com/projects/redux-starter-kit-docs/deploys/68b9b042a8e229000872db9e
😎 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.

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
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. RTK-Query Issues related to Redux-Toolkit-Query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants