Skip to content

Instantly share code, notes, and snippets.

@reime005
Last active September 14, 2019 11:40
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 reime005/b78dfda7d2f35b0ac08f3d6581a09385 to your computer and use it in GitHub Desktop.
Save reime005/b78dfda7d2f35b0ac08f3d6581a09385 to your computer and use it in GitHub Desktop.
/* src/store/rootSaga.js */
//... imports
function* handleRequest(chan) {
while (true) {
const action = yield take(chan);
yield call(sendMediaSaga, action);
}
}
function* mediaQueueSaga() {
// create a channel to queue incoming requests
const chan = yield call(channel);
// create 1 worker 'threads'
for (let i = 0; i < 1; i++) {
yield fork(handleRequest, chan);
}
while (true) {
const action = yield take(SEND_MEDIA_SAGA_ACTION);
yield put(chan, action);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment