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

23 lines
599 B
JavaScript
Raw Normal View History

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