-
Notifications
You must be signed in to change notification settings - Fork 6
Description
At the moment we mount realtime event handlers with each query and stop listening to them once that component is unmounted, this can cause data integrity issues. Instead we should maybe have one central listener that listens to all events and updates the cache.
One edge case to handle here is the queries that use "refetch" mode, it would be wasteful to refetch such queries in the background if their not mounted. Ingesting a realtime event into cache (hit or miss) is cheap. But doing refetches is expensive and should only be done if relevant for the current screen. Having said that, refetches are rare, and perhaps it's ok if the data is not fresh for queries using refetch mode, the integrity issue should be handled by guarding etc. in those rare cases where refetch is being used. A bit leaky, but might be the case of good enough.