Redux sagas Fetch only once when same id is dispatched multiple times
I’m getting a user from my API and store it in my state so I don’t have to fetch it again. Problem is that multiple components requests the user at the same time resulting in multiple concurrent fetch requests. Is there a good pattern to avoid this? This is my saga function* watchUserRequests() { yield takeEvery(actionTypes.USER_REQUESTED, userRequested); } function* userRequested(action) { const {id} = action.payload; let user = yield select(state => state.users.all[id]); // cancel if user exists if (user) return; user = yield call(userApi.get, id); yield put(userActions.userLoaded(id, banner