Last active
October 27, 2018 14:18
-
-
Save productioncoder/7a8f044bd8a20895914f82f0eba2fea4 to your computer and use it in GitHub Desktop.
Youtube fetch most popular videos by category saga
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {fork, take, takeEvery, call, all, put} from 'redux-saga/effects'; | |
/* ... */ | |
import {fetchEntity, ignoreErrors} from './index'; | |
export function* fetchMostPopularVideosByCategory(categories) { | |
const requests = categories.map(category => { | |
const wrapper = ignoreErrors(api.buildMostPopularVideosRequest, 12, false, null, category); | |
return call(wrapper); | |
}); | |
try { | |
const response = yield all(requests); | |
yield put(videoActions.mostPopularByCategory.success(response, categories)); | |
} catch (error) { | |
yield put(videoActions.mostPopularByCategory.failure(error)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment