Files
freeCodeCamp/common/app/routes/challenges/redux/reset-challenge-saga.js
2016-07-28 23:40:01 -07:00

16 lines
493 B
JavaScript

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);
});
}