Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active December 16, 2018 15:23
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/a0de3959ed924c5647c96c05d5244bdb to your computer and use it in GitHub Desktop.
Save productioncoder/a0de3959ed924c5647c96c05d5244bdb to your computer and use it in GitHub Desktop.
Most popular video sagas
import {call, fork, take } from 'redux-saga/effects';
import * as api from '../api/youtube-api';
import * as videoActions from '../actions/video';
import {REQUEST} from '../actions';
import {fetchEntity} from './index';
export function* watchMostPopularVideos() {
while (true) {
const {amount, loadDescription, nextPageToken} = yield take(videoActions.MOST_POPULAR[REQUEST]);
yield fork(fetchMostPopularVideos, amount, loadDescription, nextPageToken);
}
}
export function* fetchMostPopularVideos(amount, loadDescription, nextPageToken) {
const request = api.buildMostPopularVideosRequest.bind(null, amount, loadDescription, nextPageToken);
yield fetchEntity(request, videoActions.mostPopular);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment