-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat(useAsyncState): cancel previous promise and use latest promise #4797
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
…evious ones will be canceled
Thanks for your PR, would you mind adding some unit tests? |
Thanks for the suggestion! I've added the unit tests and updated the PR. Please let me know if any further changes are needed. |
Based on testing, I found that by default, the result of a slower previous request might override the latest one. |
Signed-off-by: davidglezz <davidgg666@gmail.com>
Add a “cancellable” parameter to ensure that only the latest Promise takes effect, canceling the previous ones. The Promise can also be manually canceled by calling cancel().