NuxtN
Nuxt13mo ago
LT

About using callOnce

Hey all,

Before the existence of the callOnce util, one of the recommended/suggested methods for initialising a store with data was to just simply call the action on app.vue (or layout.vue) which, according to my understanding, would load the data when loading the site for the first time, and then only call it again if we "hard refresh" the page.

Now, can somebody clarify what is the difference between calling a store action directly inside app.vue's setup versus using the callOnce util?

So basically, what is the functional difference between:

app.vue (or layout.vue)
<script lang="ts" setup>
await store.getData()
</script>

and

app.vue (or layout.vue)
<script lang="ts" setup>
await callOnce(async () => {
  await store.getData()
})
</script>


Cheers, thanks 👍
Was this page helpful?