I have a react application that connects to a socket and gets a list of data (initial data) from one of the channel
the issue appears while I got the list again when reconnecting or when I change the route (refresh is of course not a problem)
and then I got the list again and need to update the state again with all the list (I am doing that with REDUX)
My question i how can I check or prevent from update the state again . is there any subject that supports that? or i should check if the whole list exists in the reducer? is it also a good solution to set a state in redux that said "fetched:true" and then don't dispatch in that case
listen to the channel: (class that listen to socket server create an observable using rxjs)
socketService.server.on('list', (res: any) => {
console.dir(res);
subject$.next(res)
});
update the state in redux-thunk action:
.subscribe(vall).... {
disptach(list)....
});
socketService only connect to the socket and return a socket
reshave an unique identifier, such as anid? If so, you could usedistinctUntilChanged((prev, crt) => prev.id === crt.id)- Andrei Gătej