-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
(core) - Make Client more forgiving by sharing result sources that emit cached results #1515
Conversation
8a23d5d
to
4538812
Compare
|
8b2c2c5
to
607869b
Compare
Replace the client's counting of active operations with a single, shared operation result source in a Map. This achieves the same semaphore behaviour but replaces it with a binary semaphore-like cache, where the cached source remembers the last active result.
607869b
to
bca99c7
Compare
I'd say from a "proof of concept" perspective, this is ready and working now. I'm not quite happy with the implementation in We also need to test whether this behaviour actually improves the intuitiveness of |
7018a49
to
7fd4474
Compare
Summary
At the risk of being called edgy, this proposed change layers a third cache on top of the
Client
. Apart from the usual exchange cache (defaultcacheExchange
or Graphcache) and the React bindings' suspense/concurrent cache, this third cache is just a minor one to share results across all sources.This change replaces the
Client
's semaphore with a shared binary semaphore that only stores the result source for a given operation. Hence, an active operation now has a single source that it uses for all subscribers. Apart from the shared source on each subscription it will still emit a new operation. However, all sources for a single subscription now share an underlying source. This source ensures that all operations see the exact same result (which was only implicitly guaranteed before) and each new subscriber will receive the last previously known result if its operation doesn't immediately yield a first result.This means that it'll be harder to trip up when layering a lot of logic with shared operations that have multiple concurrent subscribers and multiple concurrent uses of
cache-and-network
request policies.Set of changes
activeOperations
type with aMap<number, ActiveOperation>
activeOperations
when it endsThe risk associated with this change right now is that the
requestPolicy
may be disregarded. We have to investigate whether anetwork-only
operation for instance still shows the expected bindings behaviour. Although, this hasn't been doing what people thought anyway.