Skip to content

OnUnsubscribe? #283

Answered by enisdenjo
JakeCooper asked this question in Q&A
Dec 15, 2021 · 2 comments · 17 replies
Discussion options

You must be logged in to vote

As per the Observable pattern, a stream is stopped with either an "error" or a "complete" event. If you dispose of the client.subscribe subscription, or if the subscription is completed by the server, or the query/mutation is done - the complete callback in the subscribed sink will be called.

On the server side, what you're looking for is therefore the onComplete server hook. It is called for each query/mutation/subscription after it has completed for whatever reason (user disconnected, server completed, client completed/unsubscribed). An same on the error side with the onError hook.

Additionally, if you're looking for hooks for when the client completely disconnects/closes the WebSocket …

Replies: 2 comments 17 replies

Comment options

You must be logged in to vote
17 replies
@gschier
Comment options

@enisdenjo
Comment options

@enisdenjo
Comment options

@gschier
Comment options

@enisdenjo
Comment options

Answer selected by enisdenjo
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #282 on December 15, 2021 20:35.