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): add useQuery, useMutation, useGet composables #409

Merged
merged 11 commits into from
Dec 7, 2023
Merged

feat(api): add useQuery, useMutation, useGet composables #409

merged 11 commits into from
Dec 7, 2023

Conversation

brc-dd
Copy link
Member

@brc-dd brc-dd commented Dec 7, 2023

closes #398


Copy link

netlify bot commented Dec 7, 2023

Deploy Preview for sefirot-docs ready!

Name Link
🔨 Latest commit 052067b
🔍 Latest deploy log https://app.netlify.com/sites/sefirot-docs/deploys/657192addaba5e000806d90d
😎 Deploy Preview https://deploy-preview-409--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 Dec 7, 2023

Deploy Preview for sefirot-story ready!

Name Link
🔨 Latest commit 052067b
🔍 Latest deploy log https://app.netlify.com/sites/sefirot-story/deploys/657192ad4616920008bc205d
😎 Deploy Preview https://deploy-preview-409--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.

@brc-dd
Copy link
Member Author

brc-dd commented Dec 7, 2023

do we have use cases where we want to mutate loading or data from outside the composable? like maybe to reset or something?

@kiaking
Copy link
Member

kiaking commented Dec 7, 2023

@brc-dd
For loading, I think we never had that use case, but data might. Like, when we want to do optimistic update 👀 I think I have done something like this in the past.

// Get single user.
const { data: user } = useQery(() => /* ... */)

const { execute: updateUser } = useMutation(() => /* ... */)

function updateUser(newUser) {
  // Update user directly since we don't need to re-fetch.
  user.value = newUser

  updateUser(/* ... */)
}

@brc-dd
Copy link
Member Author

brc-dd commented Dec 7, 2023

ok updated

lib/composables/Api.ts Outdated Show resolved Hide resolved
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.

Added the docs! Please feel free to merge it when ever you feel like it 👍

@kiaking kiaking added the enhancement New feature or request label Dec 7, 2023
docs/composables/api.md Outdated Show resolved Hide resolved
@brc-dd brc-dd merged commit a9a77e7 into main Dec 7, 2023
9 checks passed
@brc-dd brc-dd deleted the api branch December 7, 2023 09:42
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.

[Api] add Api module. e.g. useQuery composable
2 participants