diff --git a/index.js b/index.js index 42af046..7a26dc9 100644 --- a/index.js +++ b/index.js @@ -5,15 +5,22 @@ import { DevTools, LogMonitor, DebugPanel } from 'redux-devtools/lib/react'; import App from './containers/App' import configureStore, { USE_DEV_TOOLS } from './store/configureStore' import { Route, Router as RealRouter } from 'react-router' + +import { syncReduxAndRouter } from 'redux-simple-router' + import * as actions from './actions/'; import emailApp from './emailApp' + import Folders from './components/Folders' import Folder from './components/Folder' import Emails from './components/Emails' import EmailPreview from './components/EmailPreview' import Counter from './components/Counter' + import generatePageLoaders from './pageLoaders' +import createBrowserHistory from 'history/lib/createBrowserHistory' + class Router extends RealRouter { render() { console.log("Rendering Router") @@ -28,11 +35,16 @@ class Router extends RealRouter { } } + window.emailApp = emailApp; const store = configureStore(); const pageLoaders = generatePageLoaders(store.dispatch); +const history = createBrowserHistory(); + +syncReduxAndRouter(history, store) + const debugPanel = USE_DEV_TOOLS ? ( @@ -43,14 +55,14 @@ let rootElement = document.getElementById('root') render(
- + - store.dispatch(actions.initializeCounter())}/> + diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index b2aebe0..f7bb699 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -599,6 +599,11 @@ "from": "envify@>=3.0.0 <4.0.0", "resolved": "https://registry.npmjs.org/envify/-/envify-3.4.0.tgz" }, + "errno": { + "version": "0.1.4", + "from": "errno@>=0.1.3 <0.2.0", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.4.tgz" + }, "escape-html": { "version": "1.0.2", "from": "escape-html@1.0.2", @@ -1399,6 +1404,11 @@ "from": "proxy-addr@>=1.0.8 <1.1.0", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.0.8.tgz" }, + "prr": { + "version": "0.0.0", + "from": "prr@>=0.0.0 <0.1.0", + "resolved": "https://registry.npmjs.org/prr/-/prr-0.0.0.tgz" + }, "punycode": { "version": "1.3.2", "from": "punycode@>=1.2.4 <2.0.0", @@ -1539,6 +1549,11 @@ } } }, + "redux-simple-router": { + "version": "0.0.10", + "from": "redux-simple-router@>=0.0.10 <0.0.11", + "resolved": "https://registry.npmjs.org/redux-simple-router/-/redux-simple-router-0.0.10.tgz" + }, "redux-thunk": { "version": "1.0.0", "from": "redux-thunk@>=1.0.0 <2.0.0", diff --git a/package.json b/package.json index 640137c..1a6d363 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,9 @@ "uid": ">=0.0.2", "faker": ">=0.7.2", "lodash": "^3.10.1", - "history": "^1.12.0", - "react-router": "^1.0.0" + "history": "^1.13.0", + "react-router": "^1.0.0", + "redux-simple-router": "^0.0.10" }, "devDependencies": { "babel-core": "^5.6.18", diff --git a/reducers/index.js b/reducers/index.js index b24eace..8f863d6 100644 --- a/reducers/index.js +++ b/reducers/index.js @@ -2,6 +2,7 @@ import { combineReducers } from 'redux' import emailApp from '../emailApp' import { OPEN_EMAIL, REMOVED_EMAIL, INCREMENT_COUNTER, INITIALIZE_COUNTER } from '../actions'; import { FETCHED_EMAILS } from '../emailApp/actions/emailActions' +import { UPDATE_PATH, routeReducer } from 'redux-simple-router' const openEmailsReducer = function(state = [], action) { switch(action.type) { @@ -16,7 +17,9 @@ const openEmailsReducer = function(state = [], action) { const counterReducer = function(state = 0, action) { switch(action.type) { - case INITIALIZE_COUNTER: + case UPDATE_PATH: + console.log("UPDATE_PATH"); + console.log(action); return 0; case INCREMENT_COUNTER: return state + 1; @@ -33,6 +36,7 @@ const rootReducer = combineReducers({ counter: counterReducer, emailApp: emailApp.reducer, gui: guiReducer, + routing: routeReducer }); export default rootReducer;