Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

DamianGlowala
Copy link
Member

@DamianGlowala DamianGlowala commented Mar 14, 2024

πŸ”— Linked issue

resolves #26195

❓ 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

Allows clearing Nuxt data from within the async data composable (hence removing a need for knowing and/or passing a key). Original issue describes resetting Nuxt data instead (by respecting the optional default prop rather than always setting data.value to undefined). Thought this might be better to start with though; I'm open to any suggestions!

Will update the docs knowing this is a desirable addition.

πŸ“ Checklist

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

@DamianGlowala DamianGlowala self-assigned this Mar 14, 2024
Copy link

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

@TheAlexLichter
Copy link
Member

Seems like a nice DX improvement to me πŸ‘

With regards to clear (undefined) vs. reset (set to default value) - I was wondering if we need a distinction or could rely on resetting it to the default value straight away. But if that should be consistent, clearNuxtData should behave the same way, which would be tricky at the moment πŸ€”

@DamianGlowala
Copy link
Member Author

I certainly agree - this raises a question whether clearNuxtData should respect the default value. We have a couple of options:

  • make clearNuxtData respect the default value (I personally prefer this behavior; would be a breaking change though)
  • add reset function to async data which would differ from clear (setting it to the default value vs undefined)
  • add optional param to clear function which would allow either reverting to the default value or not (again, some could ask why we wouldn't have the same param for clearNuxtData)

@TheAlexLichter
Copy link
Member

I think both, clear and reset, might be confusing

Maybe updating it for v4 could be nice? πŸ€”

@DamianGlowala
Copy link
Member Author

They will be confusing, I'm sure.

Created #26269 to discuss updating it for v4.

Copy link
Contributor

nuxt-studio bot commented Mar 16, 2024

βœ… Live Preview ready!

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

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.

Add reset fn to data fetching composables
3 participants