Closed bigoper closed 3 years ago
import { cacheAction } from 'vuex-cache'; // ... const actions = { 'FETCH_STARGAZERS': cacheAction( ({ cache, commit }, payload) => ( cache.dispatch('FETCH_REPOSITORIES') .then((repos) => Promise.all(repos.map(getStargazers))) .then((stargazers) => { commit('STARGAZERS', [].concat(...stargazers)); }) ) ), 'SET_STARGAZERS': (context, payload) => { ... } }
FETCH_LISTINGSV2_CACHED: cacheAction(function({ cache, dispatch, commit }, id) { console.info('FETCH_LISTINGSV2_CACHED', id) cache.dispatch('GET_LISTINGV2', id) }), async GET_LISTINGV2({ commit }, id) { const response = await this.$axios.get('/listings/' + id, { baseURL: `https://${APISERVERS[Math.floor(Math.random() * APISERVERS.length)]}/api/v1`, headers: headers }) const { listing } = await response return listing },
Do you are using version 2 or 3? There's an issue on version 2's cacheAction.
cacheAction
(I pointed it in my review, but it was merged anyway https://github.com/superwf/vuex-cache/pull/17)
I'm following the docs
I have the followings (my code)
It works, but now I wish to do the following:
I just could not get the 'syntax' on how to use 'Promise.all, map' to work for me.