We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0e2b0a1 commit ade06c6Copy full SHA for ade06c6
src/store/index.js
@@ -36,6 +36,19 @@ const store = new Vuex.Store({
36
},
37
38
FETCH_ITEMS: ({ commit, state }, { ids }) => {
39
+ // on the client, the store itself serves as a cache.
40
+ // only fetch items that we do not already have, or has expired (3 minutes)
41
+ const now = Date.now()
42
+ ids = ids.filter(id => {
43
+ const item = state.items[id]
44
+ if (!item) {
45
+ return true
46
+ }
47
+ if (now - item.__lastUpdated > 1000 * 60 * 3) {
48
49
50
+ return false
51
+ })
52
if (ids.length) {
53
return fetchItems(ids).then(items => commit('SET_ITEMS', { items }))
54
} else {
0 commit comments