-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(useAsyncState): ensure execute return the actual data
#5167
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
base: main
Are you sure you want to change the base?
Conversation
execute return the actual dataexecute return the actual data
@vueuse/components
@vueuse/core
@vueuse/electron
@vueuse/firebase
@vueuse/integrations
@vueuse/math
@vueuse/metadata
@vueuse/nuxt
@vueuse/router
@vueuse/rxjs
@vueuse/shared
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5167 +/- ##
=======================================
Coverage 63.95% 63.95%
=======================================
Files 343 343
Lines 7838 7838
Branches 2424 2412 -12
=======================================
Hits 5013 5013
Misses 2286 2286
Partials 539 539 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
👍 |
|
I wonder if we could consider this as a fix rather than a breaking change |
| error: Ref<unknown> | ||
| execute: (delay?: number, ...args: Params) => Promise<Data> | ||
| executeImmediate: (...args: Params) => Promise<Data> | ||
| execute: (delay?: number, ...args: Params) => Promise<Data | undefined> |
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.
Maybe we should alter the return data type based on throwError?
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.
Even if throwError is set to false, the return value of execute can still be undefined, because in the error branch we don’t have a valid Data to return. Therefore, I think the return type cannot reliably be narrowed based on throwError.
I agree. I've been on the fence about this too. |
| /** | ||
| * | ||
| * An error is thrown when executing the execute function | ||
| * | ||
| * @default false | ||
| */ | ||
| throwError?: boolean |
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.
Unrelated to this PR tho, but I wonder if we should consider reverting this default. Not throwing error for a manual execute function by default feels a bit conterintutive to me
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.
Agree.
execute return the actual dataexecute return the actual data
Before submitting the PR, please make sure you do the following
fixes #123).Description
Close #5111
Additional context