Skip to content

Instantly share code, notes, and snippets.

@marocchino
Created March 20, 2018 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marocchino/f377653bb31e5ff63697cb3cd3da4f0c to your computer and use it in GitHub Desktop.
Save marocchino/f377653bb31e5ff63697cb3cd3da4f0c to your computer and use it in GitHub Desktop.
fetch monitor
someQuery(variables, { commit }) {
client.query(query, variables, { commit })
}
async query(query, variables, { commit }) {
key = uuid()
commit('monitor/PUSH', key, { root: true })
const payload await actualQuery(...)
commit('monitor/DELETE', key, { root: true })
return payload
}
export default {
namespaced: true,
state: {
array: []
},
getter: {
loading: ({array}) => array.length > 0
},
mutation: {
PUSH(state, payload) {
state.array.push(payload)
},
DELETE(state, payload) {
state.array.delete(payload)
}
}
}
payload = await query.someQuery(variables, { commit })
@marocchino
Copy link
Author

marocchino commented Mar 20, 2018

要はお互い依存しなくてもcommit渡したらなんとかなる

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment