Skip to content

Commit

Permalink
update route mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 30, 2016
1 parent 0a96b95 commit f29fe4a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sync(store, router) // done.

- When the router navigates to a new route, the store's state is updated.

- When the store's `route` state is updated, it notifies the router to navigate to the corresponding path. This enables time-traveling between routes in `vue-devtools`.
- **`store.state.route` is immutable, because it is derived state from the URL, which is the source of truth**. You should not attempt to trigger navigations by mutating the route object. Instead, just call `$router.go()`.

### License

Expand Down
11 changes: 1 addition & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,7 @@ function patchStore (store) {
route: {
mutations: {
'router/ROUTE_CHANGED': function (state, to) {
Object.keys(to).forEach(key => {
if (key !== 'matched') {
set(state, key, to[key])
}
})
Object.keys(state).forEach(key => {
if (!(key in to)) {
state[key] = null
}
})
store.state.route = to
}
}
}
Expand Down

0 comments on commit f29fe4a

Please sign in to comment.