-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reinitialize streaming updates after store persist rehydration #2545
Comments
Also I was not sure if this belonged here, but caching the subscriptions object is definitely something that sounds like a bug to me. I initially thought So if you want me to move this over to StackOverflow I would be happy to do so. |
#2266 might be a good way out of this and we could also think about doing that for hydration, but for now that PR is stalling a bit. |
So I managed to get the persist stuff working as you pointed out. The problem with redux-storage is, that by default you cannot specify which parts of the state are used for rehydration, it's always the whole persisted state (which in my case includes the api state). So what I did is I wrote a custom merger function to omit the api state while merging the persisted state, but still save everything including api state in the persist store. And use For the part about onCacheEntryAdded: |
We are in a react native app and need to persist the api data to make it possible to use the app when being offline.
After fetching the data with a query, a graphql subscription is established to get streaming updates from the api, which will only deliver incremental changes.
I did implement this as described in the docs via
onCacheEntryCreated
and update the local cache accordingly withupdateCachedData
and this works fine for the very initial load when the store is completely empty.But unfortunately as we persist the data, this will only be called once. When the app restarts and data gets rehydrated, the subscription will no longer trigger.
I think this is by design but really unfortunate in our scenario.
What we basically want is
How would you deal with this scenario?
Sidenote
I also followed your docs about Persistance and Rehydration and added the
extractRehydrationInfo
as described, but I am not quite sure what this does, as the whole redux state is rehydrated anyway including the whole api slice.Though we are not using
redux-persist
but redux-storage, but I don't think this should matter.We do not persist the
subscriptions
object in the api slice though, since this causes a memory leak increasing cache subscriptions with every restart andrefetchOnMountOrArgChange
not working properly.The text was updated successfully, but these errors were encountered: