Last active
December 16, 2018 15:23
-
-
Save productioncoder/a0de3959ed924c5647c96c05d5244bdb to your computer and use it in GitHub Desktop.
Most popular video sagas
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 {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