OnUnsubscribe? #283
-
StoryAs a enjoyer of this library I want my server, ideally my async generator, to be notified when the cleanup function, returned from client.subscribe, is called So that I can close downstream connections to other services (in this case a GRPC stream) Acceptance criteriaP0: server is notified on unsubscribe |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 17 replies
-
As per the Observable pattern, a stream is stopped with either an "error" or a "complete" event. If you dispose of the On the server side, what you're looking for is therefore the Additionally, if you're looking for hooks for when the client completely disconnects/closes the WebSocket connection, you might want to check |
Beta Was this translation helpful? Give feedback.
-
Moved to #283 (reply in thread). |
Beta Was this translation helpful? Give feedback.
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 - thecomplete
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 theonError
hook.Additionally, if you're looking for hooks for when the client completely disconnects/closes the WebSocket …