vue-pouch
vue-pouch copied to clipboard
how to use with vuex ?
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()
})
})
},
}
})