redux-first-router
Version:
think of your app in states not routes (and, yes, while keeping the address bar in sync)
17 lines (13 loc) • 469 B
JavaScript
export default (function (routesMap, selectLocationState, bag) {
return function (_ref) {
var dispatch = _ref.dispatch,
getState = _ref.getState;
var _selectLocationState = selectLocationState(getState()),
type = _selectLocationState.type;
var route = routesMap[type];
if (route && typeof route.thunk === 'function') {
return Promise.resolve(route.thunk(dispatch, getState, bag));
}
return Promise.resolve();
};
});