Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Youtube in React: comment thread watcher and worker saga
import {fork, take} from 'redux-saga/effects';
import {REQUEST} from '../actions';
import * as commentActions from '../actions/comment'
import * as api from '../api/youtube-api';
import {fetchEntity} from './index';
export function* fetchCommentThread(videoId, nextPageToken) {
const request = api.buildCommentThreadRequest.bind(null, videoId, nextPageToken);
yield fetchEntity(request, commentActions.thread, videoId);
export function* watchCommentThread() {
while(true) {
const {videoId, nextPageToken} = yield take(commentActions.COMMENT_THREAD[REQUEST]);
yield fork(fetchCommentThread, videoId, nextPageToken);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment