Created
November 3, 2018 09:38
-
-
Save productioncoder/b301e9bd1b9e133b1a5f2248a9646bed to your computer and use it in GitHub Desktop.
Youtube watch details worker saga first version
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, all, put, call} from 'redux-saga/effects'; | |
import * as watchActions from '../actions/watch'; | |
import {buildVideoDetailRequest} from '../api/youtube-api'; | |
export function* fetchWatchDetails(videoId) { | |
let requests = [ | |
buildVideoDetailRequest.bind(null, videoId), | |
]; | |
try { | |
const responses = yield all(requests.map(fn => call(fn))); | |
yield put(watchActions.details.success(responses)); | |
} catch (error) { | |
yield put(watchActions.details.failure(error)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment