Created
December 13, 2018 17:54
-
-
Save rbinksy/616cdd61450ececde1df3839a1f55166 to your computer and use it in GitHub Desktop.
Front end version of batching.
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
//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