From 6275548680004af04cfb2557cf0308ab3ad26493 Mon Sep 17 00:00:00 2001 From: Isman Usoh Date: Mon, 29 Feb 2016 13:28:07 +0700 Subject: [PATCH] Update react-router-redux-tests.ts --- .../react-router-redux-tests.ts | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/react-router-redux/react-router-redux-tests.ts b/react-router-redux/react-router-redux-tests.ts index 50978fafd..baaec2a9c 100644 --- a/react-router-redux/react-router-redux-tests.ts +++ b/react-router-redux/react-router-redux-tests.ts @@ -6,10 +6,25 @@ import { createStore, combineReducers, applyMiddleware } from 'redux'; import { browserHistory } from 'react-router'; -import { syncHistoryWithStore, routerReducer } from 'react-router-redux'; +import { syncHistoryWithStore, routerReducer, routerMiddleware, push, replace, go, goForward, goBack } from 'react-router-redux'; const reducer = combineReducers({ routing: routerReducer }); -const store = createStore(reducer); + +// Apply the middleware to the store +const middleware = routerMiddleware(browserHistory); +const store = createStore( + reducer, + applyMiddleware(middleware) +); // Create an enhanced history that syncs navigation events with the store -const history = syncHistoryWithStore(browserHistory, store) +const history = syncHistoryWithStore(browserHistory, store); +history.listen(location => console.log(location) ); +history.unsubscribe(); + +// Dispatch from anywhere like normal. +store.dispatch(push('/foo')); +store.dispatch(replace('/foo')); +store.dispatch(go(1)); +store.dispatch(goForward()); +store.dispatch(goBack());