-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(nuxt): add clearNuxtData
#5227
Conversation
β Deploy Preview for nuxt3-docs canceled.
|
With the |
@pi0 I have already added 3.api/3.utils/clear-nuxt-cache.md and describe |
for (const key of _keys) { | ||
if (nuxt.payload.data[key] !== undefined) { | ||
nuxt.payload.data[key] = undefined | ||
} | ||
|
||
if (nuxt.payload._errors[key] !== undefined) { | ||
nuxt.payload._errors[key] = undefined | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[deleted two messages]
Thanks for making PR @cawa-93. I've made few refactors to reflect last changes and also cleaning up shared state. Didn't had a change to try it please share feedback if last changes have any issues or could be improved :) |
Uncovered use case: clearNuxtData(key => key.startsWith('posts.list')) Or provide another method to get all keys in cache and filter it manually: clearNuxtData(
getNuxtDataKeys().filter(key => key.startsWith('posts.list'))
) |
Filter support seems a good idea ππΌ When constructing _keys, we can check type and if is function, use Object.keys + filter function. Feel free to make a PR. |
π Linked issue
https://github.com/nuxt/framework/discussions/4636
β Type of change
π Description
Resolves #4636
Added a simple helper function that deletes data from the internal cache by key. This method is useful if you want to invalidate the data fetching for another page.
π Checklist