Skip to content

Instantly share code, notes, and snippets.

@rbinksy
Created December 13, 2018 17:54
Show Gist options
  • Save rbinksy/616cdd61450ececde1df3839a1f55166 to your computer and use it in GitHub Desktop.
Save rbinksy/616cdd61450ececde1df3839a1f55166 to your computer and use it in GitHub Desktop.
Front end version of batching.
//usage
yield call(batchLoad, assetRequests.assets);
function* batchLoad(assetReqs, offset = 0) {
yield put({
type: ActionTypes.FETCH_ASSETREQUESTS_SUCCESS,
payload: fromJS(assetReqs)
.slice(offset, offset + 20)
.reduce(convertToMapBy('id'), Map())
.map(AssetRequest)
});
yield call(delay, 1000);
yield call(batchLoad, assetReqs, offset + 20);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment