vue-pouch icon indicating copy to clipboard operation
vue-pouch copied to clipboard

how to use with vuex ?

Open DamienFriot opened this issue 7 years ago • 1 comments

DamienFriot avatar Oct 04 '17 09:10 DamienFriot

Sorry for a year old answer. But maybe someone else might need it :-)

This is one solution I've got working last nite. Still having some issues with it. But maybe we can help each other?

export default new Vuex.Store({

  state: {
    isAuth: false
  },

  mutations: {
    auth: (state, val) => {
      state.isAuth = val
    },
  },

  actions: {

    session ({ commit }) {
      return new Promise (resolve => {
        db.getSession((err, response) => {
          if (response.userCtx.name) commit('auth', true)
          else commit('auth', false)

          resolve()
        })
      })
    },

    signIn ({ commit }, data) {
      return new Promise (resolve => {
        db.logIn(data.email, data.pass, (err, response) => {
          if (response.ok && !err) commit('auth', true)
          else commit('auth', false)

          resolve()
        })
      })
    },

    signOut ({ commit }, data) {
      return new Promise (resolve => {
        db.logOut((err, response) => {
          if (!err) commit('auth', false)
          resolve()
        })
      })
    },

  }

})

imlinus avatar Sep 13 '18 19:09 imlinus