-
-
-
-

-
-
-
-
-
-
-
-

-
-
-
-
-
+ className={undefined} />
, document.getElementById('root'));
}
@@ -31,4 +33,4 @@ if (typeof window !== 'undefined') {
// Export the function for server side rendering.
export default renderApp;
-export { matchLocation };
+export { matchPathname, configureStore };
diff --git a/src/routesConfiguration.js b/src/routesConfiguration.js
index 0c1367a6..16112dd8 100644
--- a/src/routesConfiguration.js
+++ b/src/routesConfiguration.js
@@ -3,7 +3,7 @@ import { find } from 'lodash';
import { Redirect } from 'react-router';
// This will change to `matchPath` soonish
-import matchPattern from 'react-router/matchPattern'
+import matchPattern from 'react-router/matchPattern';
import pathToRegexp from 'path-to-regexp';
import {
@@ -37,24 +37,28 @@ const routesConfiguration = [
exactly: true,
name: 'SearchPage',
component: SearchPage,
+ loadData: SearchPage.loadData,
routes: [
{
pattern: '/s/filters',
exactly: true,
name: 'SearchFiltersPage',
component: props =>
,
+ loadData: SearchPage.loadData,
},
{
pattern: '/s/listings',
exactly: true,
name: 'SearchListingsPage',
component: props =>
,
+ loadData: SearchPage.loadData,
},
{
pattern: '/s/map',
exactly: true,
name: 'SearchMapPage',
component: props =>
,
+ loadData: SearchPage.loadData,
},
],
},
@@ -276,9 +280,9 @@ const pathByRouteName = (nameToFind, routes, params = {}) =>
/**
* matchRoutesToLocation helps to figure out which routes are related to given location.
*/
-const matchRoutesToLocation = (routes, location, matchedRoutes=[], params={}) => {
+const matchRoutesToLocation = (routes, location, matchedRoutes = [], params = {}) => {
const parameters = { ...params };
- routes.forEach((route) => {
+ routes.forEach(route => {
const { exactly = false } = route;
const match = !route.pattern ? true : matchPattern(route.pattern, location, exactly);
@@ -286,7 +290,9 @@ const matchRoutesToLocation = (routes, location, matchedRoutes=[], params={}) =>
matchedRoutes.push(route);
if (match.params) {
- Object.keys(match.params).forEach(key => { parameters[key] = match.params[key]; });
+ Object.keys(match.params).forEach(key => {
+ parameters[key] = match.params[key];
+ });
}
}
@@ -296,12 +302,11 @@ const matchRoutesToLocation = (routes, location, matchedRoutes=[], params={}) =>
});
return { matchedRoutes, params: parameters };
-}
+};
-const matchPathnameCreator = routes => (
- (location, matchedRoutes=[], params={}) =>
- matchRoutesToLocation(routes, { pathname: location }, matchedRoutes, params)
-);
+const matchPathnameCreator = routes =>
+ (location, matchedRoutes = [], params = {}) =>
+ matchRoutesToLocation(routes, { pathname: location }, matchedRoutes, params);
/**
* matchRoutesToLocation helps to figure out which routes are related to given location.
diff --git a/src/sagas.js b/src/sagas.js
index ae72fac3..d0a86084 100644
--- a/src/sagas.js
+++ b/src/sagas.js
@@ -1,5 +1,6 @@
import { watchLogin, watchLogout } from './ducks/Auth.ducks';
+import { watchLoadListings } from './containers/SearchPage/SearchPage.ducks';
export default function* rootSaga() {
- yield [watchLogin(), watchLogout()];
+ yield [watchLogin(), watchLogout(), watchLoadListings()];
}
diff --git a/src/store.js b/src/store.js
index ad4f25f8..405d6139 100644
--- a/src/store.js
+++ b/src/store.js
@@ -1,8 +1,7 @@
/* eslint-disable no-underscore-dangle */
import { createStore, applyMiddleware, compose } from 'redux';
-import createSagaMiddleware from 'redux-saga';
+import createSagaMiddleware, { END } from 'redux-saga';
import createReducer from './reducers';
-import rootSaga from './sagas';
/**
* Create a new store with the given initial state. Adds Redux
@@ -21,9 +20,10 @@ export default function configureStore(initialState = {}) {
: compose;
const enhancer = composeEnhancers(applyMiddleware(...middlewares));
- const store = createStore(createReducer(), initialState, enhancer);
- sagaMiddleware.run(rootSaga);
+ const store = createStore(createReducer(), initialState, enhancer);
+ store.runSaga = sagaMiddleware.run;
+ store.close = () => store.dispatch(END);
return store;
}