Files
freeCodeCamp/common/app/routes/challenges/redux/reset-challenge-saga.js

16 lines
493 B
JavaScript
Raw Normal View History

2016-07-07 20:02:03 -07:00
import types from './types';
import { updateCurrentChallenge } from './actions';
export default function resetChallengeSaga(actions$, getState) {
return actions$
.filter(({ type }) => type === types.resetChallenge)
.map(() => {
const {
challengesApp: { challenge: dashedName },
entities: { challenge: challengeMap }
} = getState();
const currentChallenge = challengeMap[dashedName];
return updateCurrentChallenge(currentChallenge);
});
}