-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow to skip AsyncThunks using a condition callback #513
Conversation
Deploy preview for redux-starter-kit-docs ready! Built with commit 5b2fa9a https://deploy-preview-513--redux-starter-kit-docs.netlify.app |
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 5b2fa9a:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs some docs too.
src/createAsyncThunk.ts
Outdated
if ( | ||
options && | ||
options.condition && | ||
!options.condition(arg, { getState, extra }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make this a strict === false
comparison. The user might return undefined or falsy by accident. The assumption should be that the thunk is going to run unless they really say no.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
1493609
to
9294b14
Compare
9294b14
to
2647666
Compare
2647666
to
9294b14
Compare
This is my first attempt at adding a
condition
callback so that people can skipasyncThunk
execution before it even enterspending
state, depending onarg
,getState()
andextra
.(Please don't merge this before #502 and #512, I guess order of merging might be of importance for merge conflicts here 😆)