Skip to content

Instantly share code, notes, and snippets.

@superMDguy
Last active October 9, 2018 23:37
Show Gist options
  • Save superMDguy/2d8bcd3fb88d9947685f1af8d02762d6 to your computer and use it in GitHub Desktop.
Save superMDguy/2d8bcd3fb88d9947685f1af8d02762d6 to your computer and use it in GitHub Desktop.
import tuxi from 'tuxi'
import Vuex from 'vuex'
import Vue from 'vue'
import api from './api'
Vue.use(Vuex)
const store = new Vuex.Store({
strict: true, // tuxi works in strict mode!
state: {
articles: [],
articlesTask: tuxi.task(api.fetchArticles)
},
mutations: {
SET_ARTICLES(state, articles) {
state.articles = articles
}
},
actions: {
async articles({ commit, state }) {
const articles = await state.articlesTask.start()
commit('SET_ARTICLES', articles)
}
}
})
tuxi.config.vuexStore = store
// Now you can access $store.state.articlesTask in your components to look at the task's state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment