Skip to content

Commit c79dacd

Browse files
author
Guillaume Chau
committed
fix: don't notify vuex state dependencies while replaying mutations
1 parent ab61a73 commit c79dacd

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

shells/dev/target/Counter.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export default {
2828
count: state => state.count
2929
})
3030
},
31+
watch: {
32+
count (value) {
33+
console.log('%ccount new value', 'font-weight: bold;', value)
34+
}
35+
},
3136
methods: {
3237
increment () {
3338
this.$store.commit('INCREMENT', { a: 1, b: { c: 3 }})

src/backend/vuex.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
import { stringify, parse } from 'src/util'
22
import SharedData from 'src/shared-data'
33
import { set } from '../util'
4+
import Vue from 'vue'
45

56
export function initVuexBackend (hook, bridge) {
67
const store = hook.store
8+
console.log(store)
9+
10+
let originalVm = store._vm
11+
const snapshotsVm = new Vue({
12+
data: {
13+
$$state: {}
14+
},
15+
computed: originalVm.$options.computed
16+
})
717

818
const getSnapshot = () => stringify({
919
state: store.state,
@@ -103,7 +113,7 @@ export function initVuexBackend (hook, bridge) {
103113
})
104114

105115
function replayMutations (index) {
106-
const currentState = store.state
116+
store._vm = snapshotsVm
107117

108118
// Get most recent snapshot for target index
109119
// for faster replay
@@ -155,7 +165,7 @@ export function initVuexBackend (hook, bridge) {
155165
lastState = resultState
156166

157167
// Restore user state
158-
store.replaceState(currentState)
168+
store._vm = originalVm
159169

160170
return resultState
161171
}

0 commit comments

Comments
 (0)