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(useFetch): chain callbacks from createFetch and useFetch #1545

Merged
merged 3 commits into from Jul 6, 2022

Conversation

tobyzerner
Copy link
Contributor

Description

Chain beforeFetch/afterFetch/onFetchError callbacks from createFetch and useFetch, rather than useFetch overwriting them.

Additional context

closes #1310


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@antfu antfu changed the title fix(useFetch): chain callbacks from createFetch and useFetch feat(useFetch): chain callbacks from createFetch and useFetch May 3, 2022
@antfu antfu requested a review from wheatjs May 3, 2022 16:29
wheatjs
wheatjs previously approved these changes May 4, 2022
@climba03003
Copy link
Contributor

climba03003 commented May 5, 2022

It is actually a breaking change.
And overwrite of the functions is valuable feature.
For example, I have all the default behavior placed in createFetch. Then, I have a single route need to handle differently in afterFetch, chaining will raise an error in this case.

It should allow the user to choose which behavior they desire.

@antfu antfu added this to the 9.0 milestone Jul 6, 2022
@antfu
Copy link
Member

antfu commented Jul 6, 2022

@climba03003 That makes sense, do you want to introduce the option to toggle the behavior via another PR to next branch? Thanks.

@antfu antfu enabled auto-merge (squash) July 6, 2022 18:00
@antfu antfu changed the base branch from main to next July 6, 2022 18:00
@antfu antfu disabled auto-merge July 6, 2022 18:00
@antfu antfu merged commit 088308e into vueuse:next Jul 6, 2022
@climba03003
Copy link
Contributor

I will send a PR when I have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chain beforeFetch/afterFetch/onFetchError from createFetch and useFetch
4 participants