Files
freeCodeCamp/common/app/redux/fetch-challenges-saga.js

15 lines
513 B
JavaScript
Raw Normal View History

2016-03-21 15:39:45 -07:00
import { fetchChallenges } from './types';
2016-05-06 16:04:23 -07:00
import { createErrorObserable, fetchChallengesCompleted } from './actions';
2016-03-21 15:39:45 -07:00
2016-04-24 21:54:48 -07:00
export default function fetchChallengesSaga(action$, getState, { services }) {
return action$
.filter(action => action.type === fetchChallenges)
.flatMap(() => {
return services.readService$({ service: 'map' })
.map(({ entities, result } = {}) => {
return fetchChallengesCompleted(entities, result);
})
2016-05-06 16:04:23 -07:00
.catch(createErrorObserable);
2016-04-24 21:54:48 -07:00
});
}