Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
simplevuestore
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Adam Procter
simplevuestore
Commits
ef3736b5
Commit
ef3736b5
authored
Apr 11, 2019
by
Adam Procter
💩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
live replication
parent
a4e7256e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
8 deletions
+34
-8
src/store.js
src/store.js
+25
-0
src/views/Home.vue
src/views/Home.vue
+9
-8
No files found.
src/store.js
View file @
ef3736b5
...
...
@@ -32,12 +32,35 @@ const store = new Vuex.Store({
},
actions
:
{
SYNC_DB
()
{
console
.
log
(
'
sync
'
)
pouchdb
.
sync
(
remote
,
{
live
:
true
,
retry
:
true
})
},
CHANGES_DBSIDE
()
{
console
.
log
(
'
yo
'
)
// call mutation when you hear DB changes
pouchdb
.
changes
({
since
:
'
now
'
,
include_docs
:
true
})
.
on
(
'
change
'
,
function
(
change
)
{
// received a change
// dbupdatefav = change.doc.flavour
console
.
log
(
change
)
store
.
commit
(
'
CHANGE_STATE
'
,
change
.
doc
.
flavour
)
})
.
on
(
'
error
'
,
function
(
err
)
{
// handle errors
console
.
log
(
err
)
})
},
INCOMING_CHANGE
(
_state
,
event
)
{
var
id
=
'
myfav
'
store
.
commit
(
'
CHANGE_STATE
'
,
event
)
// send change also to the pouch
pouchdb
.
get
(
'
myfav
'
)
...
...
@@ -59,8 +82,10 @@ const store = new Vuex.Store({
pouchdb
.
put
({
_id
:
id
,
flavour
:
event
})
}
})
store
.
dispatch
(
'
CHANGES_DBSIDE
'
)
}
},
getters
:
{
currentflavour
:
state
=>
{
return
state
.
flavour
...
...
src/views/Home.vue
View file @
ef3736b5
...
...
@@ -27,14 +27,15 @@ export default {
},
//any mutations are put into the stepfwd array
created
()
{
this
.
$store
.
subscribe
(
mutation
=>
{
if
(
mutation
.
type
!==
CLEAR_STATE
)
{
this
.
stepfwd
.
push
(
mutation
)
}
if
(
this
.
newMutation
)
{
this
.
stepback
=
[]
}
})
this
.
$store
.
dispatch
(
'
CHANGES_DBSIDE
'
),
this
.
$store
.
subscribe
(
mutation
=>
{
if
(
mutation
.
type
!==
CLEAR_STATE
)
{
this
.
stepfwd
.
push
(
mutation
)
}
if
(
this
.
newMutation
)
{
this
.
stepback
=
[]
}
})
},
methods
:
{
fwd
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment