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

Open
wants to merge 2 commits into
base: v4
Choose a base branch
from
Open

feat: add updateQuery to useQuery #1552

wants to merge 2 commits into from

Conversation

syllomex
Copy link

@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
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.

None yet

1 participant