-
Notifications
You must be signed in to change notification settings - Fork 653
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
[🗄️ cache] Make ApolloStore.publish() suspend #5755
Conversation
✅ Deploy Preview for apollo-android-docs canceled.
|
// Because subscribe is called from a background thread, give some time to be effective | ||
delay(500) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an interesting one. If we want a guarantee that .watch()
subscribes synchronously, we probably need to go back to "interceptors do their own dispatcher switch". I want to measure how costly the thread switch is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚙️
* Write an operation data to the store and optionally publish changes of [Record] which have changed, | ||
* that will notify any watcher that depends on these [Record] to re-fetch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Write an operation data to the store and optionally publish changes of [Record] which have changed, | |
* that will notify any watcher that depends on these [Record] to re-fetch. | |
* Write an operation data to the store. |
Or maybe do we want to highlight it a bit more?
* Write an operation data to the store and optionally publish changes of [Record] which have changed, | |
* that will notify any watcher that depends on these [Record] to re-fetch. | |
* Write an operation data to the store. Call [publish] with the returned keys to notify any watcher that depends on these [Record] to re-fetch. |
(same for writeFragment
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call out. I added a @see publish
tag so hopefully it should be enough.
Made
publish
suspend so that the cache writers wait for the readers and no cache key event is lost. The buffer of size 64 is still there to smooth things out.Incubating cache gets removed
publish
parameter.Stable cache gets overloads
writeFoo()
functions. The ones with apublish
parameter should probably be deprecated but I'm not 100% sure yet.Next steps:
watch()
return aFusibleFlow
so that the user has control of the buffering there.ApolloStore.writeFoo(publish)
See #3920