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

feat: useAsync add params & autoCancel #112

Merged
merged 3 commits into from
Nov 3, 2019
Merged

feat: useAsync add params & autoCancel #112

merged 3 commits into from
Nov 3, 2019

Conversation

ttys026
Copy link
Collaborator

@ttys026 ttys026 commented Oct 28, 2019

resolve #65, resolve #69

@vercel
Copy link

vercel bot commented Oct 28, 2019

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://zeit.co/umijs/hooks/n3yrjrb58
🌍 Preview: https://hooks-git-perf-useasync.umijs.now.sh

Copy link
Collaborator

@awmleer awmleer left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@brickspert brickspert left a comment

Choose a reason for hiding this comment

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

should update the doc~

}
if (runCount === count.current) {
if (!autoCancel || runCount === count.current) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is best to add a note here.
because it‘s consistent with the above conditions.
it is easy to think that it is redundant.

@@ -120,24 +125,25 @@ function useAsync<Result = any>(
// 确保不会返回被取消的结果
const runCount = count.current;
set(s => ({ ...s, loading: true }));
params.current = args;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be in front of set(s => ({ ...s, loading: true }));

run: promiseReturn,
timer: {
stop: noop,
resume: promiseReturn,
pause: noop,
},
});
const { autoCancel = true } = _options;
Copy link
Collaborator

Choose a reason for hiding this comment

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

autoCancel is not a good name~~
but i don't hav any idea~ hhh

@ttys026
Copy link
Collaborator Author

ttys026 commented Nov 2, 2019

should update the doc~

docs will be rewritten in the docs branch

@brickspert brickspert merged commit b116ef7 into feature Nov 3, 2019
@delete-merged-branch delete-merged-branch bot deleted the perf/useAsync branch November 3, 2019 05:48
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.

3 participants