Skip to content
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

(graphcache) - Fix offlineExchange timing after rehydration #1019

Merged
merged 2 commits into from
Sep 30, 2020

Conversation

kitten
Copy link
Member

@kitten kitten commented Sep 30, 2020

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Sep 30, 2020

🦋 Changeset detected

Latest commit: 4fcc210

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@urql/exchange-graphcache Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -249,10 +250,15 @@ export const cacheExchange = (opts?: CacheExchangeOpts): Exchange => ({
// If no hydration takes place we replace this stream with an empty one
const bufferedOps$ = hydration
? pipe(
sharedOps$,
buffer(fromPromise(hydration)),
combine(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works because combine can retroactively still resolve an operation synchronously once the first operation comes in. This lets bufferedOps$ hang in its active state for as long or short as needed.

buffer on the other hand may not emit when its list of values is empty, but would wait for the next signal if then a new event comes in. Because we'd before only wait for one buffer output though and have one input event, there are conditions where bufferedOps$ would stay active indefinitely.

@kitten kitten merged commit d8a09c6 into main Sep 30, 2020
@kitten kitten deleted the fix/offline-exchange-timing branch September 30, 2020 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants