Add unsubscribe method so client can unsubscribe from topics #90
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi
My application is long running and the client will subscribe and unsubscribe to different topics during its lifetime. To this end this PR adds an
unsubscribe
method to go along with thesubscribe
method.I figure that other users might also benefit from this addition, thus this PR.
The method returns
True
and logs a warning if a request is made to unsubscribe a topic which does not exist. This is in line with the behaviour offastapi_websocket_pubsub.event_notifier.EventNotifier.unsubscribe
which also returnsTrue
if a subscription is removed with a non-existent subscriber id.I see that the current test cases are quite readable and appear like best-practice examples of how to use the library. I don't want to disturb that style with tedious tests. Do let me know if you think test cases are required.
Br Eskild