(core) - Avoid dispatching an operation for already active cache-first/only operations #1600
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Previously, in #1515 we merged the groundwork for making identical operations that are run concurrently more intuitive. Namely, when an active source is active multiple times then the sources that newly become active will have the last known result replayed. (There was one bug in there that's fixed in here; See "Set of changes")
We can use the same principle to make concurrent operations in general more intuitive. While it'd seem to make sense to create some kind of "result cache" that prevents unnecessary work, we now have the foundation that we need to make this intuitive and seamless, on top of existing logic.
With these changes applied we will now not dispatch a new operation on the
Client
and instead use the replayed result when the request policy isn'tnetwork-only
orcache-and-network
(since these intuitively instruct the cache to fetch). Instead whencache-first
orcache-only
are used and a replay result exists, theClient
will only issue the replayed result and will not do anything else.Set of changes
replayOnStart
source wouldn't reset thereplay
value toundefined
.'pre' | 'post'
mode forreplayOnStart
where'pre'
is the existing behaviour and'post'
issues thestart()
if no replay result is available