rxjs-grpc
rxjs-grpc copied to clipboard
Dispose the stream if last subscriber terminates.
In our workflow server is streaming until nobody is listening to. We don't get this information with the current observable. I had to fix this issue in a very similar fashion to this pull request at work. I have tried to isolate the necessary change to address the issue. I did not test the changes, especially because I have updated the rxjs requirement at work, and this meant a complete different interface. I hope this patch delivers the "no more subscribers" information to stream source.
Hi!
Thanks for the finding!
What does the finally
operator help in this case? Can't we just return a call to cancel as unsubscribe function from the Observable factory function?
Hi kondi!
Yes, that would be a solution. My old PR had the issue with canceling the call prematurely on first subscriber's unsubscription. I have merged the changes that I made for work and updated the PR. I had to clean A LOT OF code, and I couldn't test this version if it works, yet. However, I hope it gives you the idea.
Main decision to make is whether or not to replay the stream on consecutive subscribers to the shared observable.
This solves only half the problem, as our server still keeps publishing without any care on the call status.