So I have API fetch request to return back with a list of 1000 objects..=> I use saga yield put API to update the state in reducer. Now it is working well but I feel like there is a big room for speed optimization like lazy-loading.
Has anyone tried to update and pass the result to the Store in reducer as they come?
here is my pseudo code:
export const API_REQUEST = () => {
const API_ENDPOINT = `${API_URL}/api/2500/banners`
return fetch(API_ENDPOINT, {
method: "GET",
dataType: "json",
}).then(function(response) {
if (response.status >= 200 && response.status < 300) {
return response.json().then(function(results) {
let banners = results.banners;
return banners
})
}
const banners = yield call(API_REQUEST)
yield put({
type: "BANNERS_LOADED",
banners
})
and the above call updates the store reducer and subsequently updates the UI in browser. I am trying to implement lazy load..or something similar. if there is any suggestion, I would like to hear about it.
thanks!