So I implemented a websocket using this pattern https://redux-toolkit.js.org/rtk-query/usage/streaming-updates
it works fine but my issue is that I would like to limit the total entries to 30 (websocket is sending a lot, and fast). I would need a queue like FIFO to keep my list updated but limited. What would be the pattern to do that , how should I write it ?
EDIT:
I came up with the solution same you suggested, do you think this implementation is ok? (actually it works very well)
const currentCache = getCacheEntry();
if(currentCache.data && currentCache.data.ids.length === MAX_ENTRY) {
const toRemove = currentCache.data.ids[0]
nearTxAdapter.removeOne(draft, toRemove);
}
nearTxAdapter.addOne(draft, data);