-
-
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
Implement active teardowns and add useQuery features to useSubscription #410
Conversation
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.
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.
This looks good to me, so the only thing left to do is look at what's wrong in the tests I assume
Turns out I just forgot to use |
Verified this to be working on CodeSandbox, but more testing needed. There's a prerelease on npm under the |
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, likeexecuteSubscription
andargs.pause
. It also ensures that thehandler
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 propagatingClose
signals correctly, so the use ofonEnd
would prevent unsubscriptions from propagating upwards.