-
-
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
feat(createAsyncThunk): async condition #1496
Conversation
✔️ Deploy Preview for redux-starter-kit-docs ready! 🔨 Explore the source changes: f3228a1 🔍 Inspect the deploy log: https://app.netlify.com/sites/redux-starter-kit-docs/deploys/613b4f499f18e60008ea1b57 😎 Browse the preview: https://deploy-preview-1496--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 f3228a1:
|
options.condition(arg, { getState, extra }) === false | ||
) { | ||
let conditionResult = options?.condition?.(arg, { getState, extra }) | ||
if (conditionResult instanceof Promise) { |
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.
Is instanceof
good enough or do we want to support 3rd-party thenables?
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.
Also what should happen when an error is thrown in a synchronous condition
?
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.
Hmm. "then" in conditionResult
might be better, you're right.
As for an error in condition
, so far that was just thrown as it was and I'm pretty okay. Might even make sense to remove the try..catch block above to mimick that.
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.
As for an error in condition, so far that was just thrown as it was and I'm pretty okay. Might even make sense to remove the try..catch block above to mimick that.
Okay, let's do it that way. (I somewhat dislike the fact that in this case rejected
is dispatched without corresponding pending
, but that's a separate issue.)
0cd6708
to
8d7848a
Compare
008ad3a
to
f3228a1
Compare
Looks good to me! I'm gonna approve this one, but not merge it yet because I think we'll still want to release a patch release before the next minor and this is stuff for a minor - so please feel free to use the CodeSandbox build in the meantime. |
closes #1494