Skip to content

Commit b4c24c1

Browse files
committed
support vuex 2.0 migration
1 parent e28dd02 commit b4c24c1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ exports.sync = function (store, router) {
66
var currentPath
77

88
// sync router on store change
9-
store.watch(
9+
store._vm.$watch(
1010
function (state) {
1111
return state.route
1212
},
@@ -29,20 +29,21 @@ exports.sync = function (store, router) {
2929
}
3030
var to = transition.to
3131
currentPath = to.path
32-
store.dispatch('router/ROUTE_CHANGED', to)
32+
var commit = store.commit || store.dispatch
33+
commit('router/ROUTE_CHANGED', to)
3334
})
3435
}
3536

3637
function patchStore (store) {
3738
// add state
3839
var set = store._vm.constructor.set
39-
store._dispatching = true
40+
store._dispatching = store._committing = true
4041
set(store.state, 'route', {
4142
path: '',
4243
query: null,
4344
params: null
4445
})
45-
store._dispatching = false
46+
store._dispatching = store._committing = false
4647
// add mutations
4748
store.hotUpdate({
4849
modules: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vuex-router-sync",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "Effortlessly keep vue-router and vuex store in sync.",
55
"main": "index.js",
66
"repository": {

0 commit comments

Comments
 (0)