Created
March 20, 2018 19:59
-
-
Save marocchino/f377653bb31e5ff63697cb3cd3da4f0c to your computer and use it in GitHub Desktop.
fetch monitor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| someQuery(variables, { commit }) { | |
| client.query(query, variables, { commit }) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| payload = await query.someQuery(variables, { commit }) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
要はお互い依存しなくてもcommit渡したらなんとかなる