Skip to content

Commit

Permalink
promisify getChannels action to wait before calling getVideos
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeldesu committed Jan 25, 2020
1 parent 4cefa02 commit 4bc7804
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ export default {
]),
async created() {
this.$store.dispatch('getChannels');
this.$store.dispatch('getVideos');
this.$store.dispatch('getChannels').then(() => {
this.$store.dispatch('getVideos');
});
},
};
</script>
Expand Down
7 changes: 6 additions & 1 deletion src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ export default {
},

async getChannels({ commit }) {
commit(types.GET_CHANNELS, await database.channels.toArray());
return new Promise((resolve) => {
database.channels.toArray().then((result) => {
commit(types.GET_CHANNELS, result);
resolve();
});
});
},

selectChannel({ commit, dispatch }, index) {
Expand Down

0 comments on commit 4bc7804

Please # to comment.