Skip to content

4 Installation with vuex

David Grill edited this page Jun 2, 2017 · 1 revision

If you're using vuex, you'll have a all your list state managment ready to use !

Here is your ids.js file :

import Vue from 'vue'
import VueIdb from 'vue-idb'

Vue.use(VueIdb)

export default new VueIdb({
  database: 'test',
  schemas: [
    { tests: 'id, label, created_at, updated_at' }
  ],
  options: {
    tests: { type: 'list', primary: 'id', label: 'title', updated_at: 'updated_at' }
  },
  apis: {
    bigs: {
      all: () => axios.get('/dev/data/data.json')
    }
  }
})

Then, just import it in your store.js file :

import Vue from 'vue'
import Vuex from 'vuex'
import VueIdb from './idb'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    hydrated: false
  },
  actions: {
  },
  mutations: {
    'DELETE_INDEXED_DB'(){}
  },
  modules: VueIdb.modules,
  getters: {
    hydrated: state => state.hydrated
  },
  plugins: [ VueIdb.plugin ],
  strict: true
})
Clone this wiki locally