AxelSorensen
Composables that depend on eachother
I want to cache the data so I don't need to refetch it on each page navigation. However much of the data fetched from my composables relies on the current user.
I do "await getCurrentUser" before passing this value into many of my functions, however I want to clear all my caches and refetch when a user signs in or out. Usually I would use refreshNuxtData but it seems to me that this only works with data in the same scope:
https://github.com/nuxt/nuxt/issues/26165
Having to export a refresh function from each of my useasyncdata composables and then running them all at the same time seems cumbersome
Is there perhaps a better way?
9 replies
Calling child function in dynamic route [id].vue
Ok, I actually ended up solving this!
So if anyone has the same issue:
It doesn't work if you use the dynamic route structure
pages/projects/[id].vue
But it does work if you use:
pages/projects/[id]/index.vue
2 replies
Automatic pending state for data being fetched?
Thanks @Mähh
I would really like to not have to initialize my variables as objects with pending and data keys as this clutters the code.
My dream scenario is simply that I can somehow check if a variable is currently in a "fetching state"
For example imagine:
I wonder whether a value that is currently being assigned with await has some kind of metadata associated with it that I could query to trigger my loading animation.
30 replies
Automatic pending state for data being fetched?
Take a look at my example in my post:
I want a wrapper around any data, that will show the data if it is fetched or default to a loading indicator.
This would mean that in my main app I could handle all the data fetching and as long as i wrap my data in this wrapper:
<wrapper>{{data}}</wrapper>
or pass it as a prop
<wrapper :data="data"/>
Would show "loading" or "data" depending on the fetchstate of the given data
30 replies
Automatic pending state for data being fetched?
Right, but what I would really love is to automatically detect that data is being awaited and whenever it is, display some arbitrary loading indicator. I know this can be done with <Suspense/> in React for example, but again this only applies to first time the data is being fetched it seems
30 replies