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(api): allow watching options in useQuery #466

Merged
merged 1 commit into from
Feb 6, 2024
Merged

feat(api): allow watching options in useQuery #466

merged 1 commit into from
Feb 6, 2024

Conversation

brc-dd
Copy link
Member

@brc-dd brc-dd commented Feb 6, 2024

Before:

export function usePostPage(options: MaybeRefOrGetter<UsePostPageOptions>) {
  const query = useQuery(async (http) => {...})

  watch(() => toValue(options), query.execute, { deep: true })

  return query
}

After:

export function usePostPage(options: MaybeRefOrGetter<UsePostPageOptions>) {
  return useQuery(async (http) => {...}, { watch: () => toValue(options) })
}

Nuxt's useAsyncData also supports passing watch sources, so useQuerySsr already supports this.

@brc-dd brc-dd added the enhancement New feature or request label Feb 6, 2024
@brc-dd brc-dd requested a review from kiaking February 6, 2024 05:25
@brc-dd brc-dd self-assigned this Feb 6, 2024
Copy link

netlify bot commented Feb 6, 2024

Deploy Preview for sefirot-docs ready!

Name Link
🔨 Latest commit f824b18
🔍 Latest deploy log https://app.netlify.com/sites/sefirot-docs/deploys/65c1c2d3addb9d000853cc9f
😎 Deploy Preview https://deploy-preview-466--sefirot-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Feb 6, 2024

Deploy Preview for sefirot-story ready!

Name Link
🔨 Latest commit f824b18
🔍 Latest deploy log https://app.netlify.com/sites/sefirot-story/deploys/65c1c2d3546601000723df52
😎 Deploy Preview https://deploy-preview-466--sefirot-story.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@kiaking kiaking left a comment

Choose a reason for hiding this comment

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

Ahhh smart 👍 I like it.

@brc-dd brc-dd merged commit 3a5e808 into main Feb 6, 2024
9 checks passed
@brc-dd brc-dd deleted the query/watch branch February 6, 2024 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants