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(nuxt)!: remove pending from data fetching composables #25864

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

drowhannn
Copy link

@drowhannn drowhannn commented Feb 19, 2024

πŸ”— Linked issue

resolves #25225

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

I have removed pending in favor of status as discussed in issue #25225.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.

Copy link

stackblitz bot commented Feb 19, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

nuxt-studio bot commented Feb 19, 2024

βœ… Live Preview ready!

Name Edit Preview Latest Commit
Nuxt Docs Edit on Studio β†—οΈŽ View Live Preview 65be561

@DamianGlowala DamianGlowala changed the title feat(nuxt): remove pending from data fetching composables feat(nuxt)!: remove pending from data fetching composables Feb 23, 2024
@UfukUstali
Copy link

UfukUstali commented Feb 28, 2024

If there are going to be breaking changes in the useFetch's signature I think it would be also be good to at least consider returning a reactive object rather than individual refs.

My reasoning is because currently returned values are refs we cannot leverage discriminated unions. With a reactive object however because it is not wrapped with refs typescript can build discriminated unions around it's type.

I had a working wrapper around the current useFetch already that is properly typed to leverage the benefits of the change I will post the repo here (or in the issue that we decide to track this in if that were to happen) once I clean it up a bit more and if there is any interest.

Benefits:

Simplified type checks around useFetch because we can just check the status and be sure that data is also there (for clarification this is already the case just typescript is not aware of it)

Improved DX for the reasons listed above

Downsides:

We lose the ability to destructure the useFetch call due to reactivity breaking

Potentially and most importantly a rather tedious migration experience (both in terms of code and convention/habits) for people that were using the destructuring pattern extensively

These were the ones that were obvious to me at first glance I am sure that there are more implications around this kind of a change that I am not aware of.

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.

Remove pending in favor of status in data fetching composables
4 participants