freeCodeCamp/client/sagas/hard-go-to-saga.js

17 lines
445 B
JavaScript
Raw Normal View History

2016-03-03 06:19:04 +00:00
import { hardGoTo } from '../../common/app/redux/types';
2016-04-25 04:54:48 +00:00
export default function hardGoToSaga(action$, getState, { location }) {
return action$
.filter(({ type }) => type === hardGoTo)
.map(({ payload = '/map' }) => {
if (!location.pathname) {
return {
type: 'app.error',
error: new Error('no location object found')
};
}
location.pathname = payload;
return null;
});
}