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: add updateQuery to useQuery #1552

Merged
merged 2 commits into from
Aug 14, 2024
Merged

feat: add updateQuery to useQuery #1552

merged 2 commits into from
Aug 14, 2024

Conversation

syllomex
Copy link
Contributor

@syllomex syllomex commented May 2, 2024

The updateQuery is something I use a lot while developing in React. I find it particularly useful because, in many cases, it eliminates the need to use readQuery and writeQuery. I just created a function that calls the existing updateQuery function in the ObservableQuery and returned it in the useQuery, so the cache of a query can be modified like this:

selectedChannelQuery.updateQuery(previousResult => ({
  ...previousResult,
  channel: {
    ...previousResult.channel,
    messages: [
      ...previousResult.channel.messages,
      result?.data.message,
    ],
  },
}))

@syllomex syllomex changed the title Add updateQuery to useQuery feat: add updateQuery to useQuery May 2, 2024
@Akryum Akryum merged commit d1098be into vuejs:v4 Aug 14, 2024
9 checks passed
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.

2 participants