Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active October 27, 2018 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save productioncoder/7a8f044bd8a20895914f82f0eba2fea4 to your computer and use it in GitHub Desktop.
Save productioncoder/7a8f044bd8a20895914f82f0eba2fea4 to your computer and use it in GitHub Desktop.
Youtube fetch most popular videos by category saga
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