0.3.3 • Published 9 years ago

vue-router-redux v0.3.3

Weekly downloads
5
License
Apache-2.0
Repository
-
Last release
9 years ago

vue-router-redux(3) -- effortlessly keep vue-router and redux store in sync

usage

$ npm install --save vue-router-redux
# or
$ yarn add vue-router-redux
import Vue from 'vue'
import VueRouter from 'vue-router'
import {createStore, applyMiddleware, combineReducers} from 'redux'
import {sync, routerReducer as route, routerMiddleware} from 'vue-router-redux' 

Vue.use(VueRouter)

const router = new VueRouter(/* routes */)

const store = createStore(
  combineReducers({route}),
  applyMiddleware(routerMiddleware(router))

sync(store, router) // done.

// bootstrap your app...

how does it work?

  • it adds a route module into the store, which contains the state representing the current route:
store.route.current.path   // current path (string)
store.route.current.params // current params (object)
store.route.current.query  // current query (object)
  • when the router navigates to a new route, the store's state is updated.
0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.2.0

9 years ago

0.1.2

9 years ago