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

Implement active teardowns and add useQuery features to useSubscription #410

Merged
merged 12 commits into from
Aug 26, 2019

Conversation

kitten
Copy link
Member

@kitten kitten commented Aug 26, 2019

Resolve #407

I think the idea of adding "active teardowns" is pretty valuable. It may be required in the future for someone to actively cancel ongoing queries from exchanges. This is already necessary to correctly implement ending subscriptions.

This hence also adds missing features to the useSubscription hook, like executeSubscription and args.pause. It also ensures that the handler arg is a constant ref, since reexecuting subscriptions when it changes wouldn't make much sense.

Wonka had a slight bug in onEnd. The operator wasn't propagating Close signals correctly, so the use of onEnd would prevent unsubscriptions from propagating upwards.

kitten added 5 commits August 26, 2019 14:12
There was a small bug in Wonka's onEnd operator
where the Close signal wasn't propagated
upwards after triggering the onEnd callback.

Hence only one onEnd operator at a time would work
and any chain of sources with onEnd in them wouldn't
propagate unsubscriptions upwards correctly.

This potentially had some negative implications
for our cancelled requests.

Further testing needed!
handler changes shouldn't trigger a new subscription
as it wouldn't make much sense. The events from a
subscription have already passed, so it's too late
to swap it out. Instead we can keep a constant ref.
@kitten kitten requested a review from JoviDeCroock August 26, 2019 13:40
Copy link
Collaborator

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

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

This looks good to me, so the only thing left to do is look at what's wrong in the tests I assume

@kitten
Copy link
Member Author

kitten commented Aug 26, 2019

Turns out I just forgot to use useImmediateEffect, but it should be fine now 👍

@kitten
Copy link
Member Author

kitten commented Aug 26, 2019

Verified this to be working on CodeSandbox, but more testing needed. There's a prerelease on npm under the next tag with version 1.4.1-next.1

@kitten kitten merged commit b904439 into master Aug 26, 2019
@kitten kitten deleted the feat/active-teardowns branch August 26, 2019 23:42
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.

Completed subscription not reflected in hook data
2 participants