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