redux-saga-job-queue

0.2.0 • Public • Published

redux-saga-job-queue

Queue same redux saga tasks and run them in a batch.

Install

Library is written for ES modules

npm install redux-saga-job-queue

Usage

Lets assume that you already have it installed. First we import it.

import { createInteractiveQueue } from 'redux-saga-job-queue';

Second, we need to define a task that is going to be called for each item.

function downloadFile({ payload }) {
  const payload = yield call(fetch, payload);
  yield put({
    type: 'FILE_READY',
    payload,
  });
}

Run the jobs in three parallel threads

function* downloadFiles(files) {
  const queue = createInteractiveQueue({
    items: files,
    jobFactory: downloadFile,
    concurrency: 3,
  });
  yield call(queue.run);
}

Package Sidebar

Install

npm i redux-saga-job-queue

Weekly Downloads

5

Version

0.2.0

License

MIT

Unpacked Size

29.8 kB

Total Files

9

Last publish

Collaborators

  • just-paja