Skip to content
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

Merged
merged 7 commits into from
Apr 19, 2020

Conversation

phryneas
Copy link
Member

This is my first attempt at adding a condition callback so that people can skip asyncThunk execution before it even enters pending state, depending on arg, getState() and extra.

(Please don't merge this before #502 and #512, I guess order of merging might be of importance for merge conflicts here 😆)

@netlify
Copy link

netlify bot commented Apr 19, 2020

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

Built with commit 5b2fa9a

https://deploy-preview-513--redux-starter-kit-docs.netlify.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 19, 2020

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:

Sandbox Source
delicate-hill-xl4x8 Configuration
shy-fire-lke4i Configuration
nervous-rgb-w16hr Configuration

Copy link
Collaborator

@markerikson markerikson left a 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.

if (
options &&
options.condition &&
!options.condition(arg, { getState, extra })
Copy link
Collaborator

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

@markerikson markerikson merged commit 2b1fca3 into reduxjs:master Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants