Commit 43cfabf6 authored by Adam Procter's avatar Adam Procter 💩

Merge branch 'changes'

parents a4e7256e 84b6c5fa
......@@ -32,12 +32,38 @@ const store = new Vuex.Store({
},
actions: {
SYNC_DB() {
pouchdb.sync(remote, { live: true, retry: true })
// do one way, one-off sync from the server until completion
pouchdb.replicate.from(remote).on('complete', function(info) {
// then two-way, continuous, retriable sync
pouchdb
.sync(remote, { live: true, retry: true })
.on('change', function(info) {
// handle change
//console.log(info.change.docs[0].flavour)
store.commit('CHANGE_STATE', info.change.docs[0].flavour)
})
.on('paused', function(err) {
// replication paused (e.g. replication up to date, user went offline)
})
.on('active', function() {
// replicate resumed (e.g. new changes replicating, user went back online)
})
.on('denied', function(err) {
// a document failed to replicate (e.g. due to permissions)
})
.on('complete', function(info) {
// handle complete
})
.on('error', function(err) {
// handle error
})
})
},
INCOMING_CHANGE(_state, event) {
var id = 'myfav'
store.commit('CHANGE_STATE', event)
// send change also to the pouch
pouchdb
.get('myfav')
......@@ -61,6 +87,7 @@ const store = new Vuex.Store({
})
}
},
getters: {
currentflavour: state => {
return state.flavour
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment