-
Notifications
You must be signed in to change notification settings - Fork 661
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
Apollo 2.3.0 does not trigger cache changes when cache is populated first time. #2531
Comments
Thanks for the bug report! Can you share more details about the scenario?
|
The cache is populated from query and changes are detected with ApolloStore.RecordChangeSubscriber. |
Thanks! This seems to work for me. Can you double check that you're holding the reference to the |
I am switching from |
Where do you store the reference to the class MyFragment: Fragment() {
val subscriber = object : ApolloStore.RecordChangeSubscriber {
override fun onCacheRecordsChanged(changedRecordKeys: Set<String>) {
println("onCacheRecordsChanged $changedRecordKeys")
}
}
override fun onCreateView() {
apolloClient.apolloStore.subscribe(subscriber)
}
} The below will not work: class MyFragment: Fragment() {
override fun onCreateView() {
val subscriber = object : ApolloStore.RecordChangeSubscriber {
override fun onCacheRecordsChanged(changedRecordKeys: Set<String>) {
println("onCacheRecordsChanged $changedRecordKeys")
}
}
apolloClient.apolloStore.subscribe(subscriber)
// the subscriber will be garbage collected soon after this method finishes and the listener will not be called
}
} |
|
I made a small snippet there: https://github.com/martinbonnin/apollo-android-samples/blob/7d971f94b5506d5293b7f9243aa820a6bc3d5a6f/cache-record-subscriber/src/test/kotlin/MainTest.kt#L38 Can you see anything that's different from from your setup there? |
I have checked all my code and there is one more component (singleton created and subscribed in Application.class) and it observes cache with query. Unfortunately it is not triggered too. Maybe is it a problem with deprecated responseFetchers?
|
I guess the next step is put a breakpoint in |
Yeah, I gonna test it with debugger and try to find an issue. Thanks for your help! |
This might be linked to #2537 although that other issues apparently also happens with 2.2.0 |
I have found the problem: In RealApolloStore:
|
@piotr-pawlowski there is a potential fix in #2538. |
I tested version |
This is expected, the patch isn't released yet. The latest snapshot is
|
Ok, version |
Nice! Glad to hear that
This bug looks different, let's move the discussion over there. |
Summary
Apollo 2.3.0 does not trigger cache changes when cache is populated first time. On 2.2.0 version everything is fine.
Version
2.3.0.
The text was updated successfully, but these errors were encountered: