-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Firstly, thanks for developing this library, the API is great.
What feels somewhat missing though is an easy way to unsubscribe after using EventBus.on
I'd like to propose two patterns for this, both of which I think would be very trivial to implement:
bus.on(MyEvent, handler)
# unsubscribe with the same handler and event
bus.remove(MyEvent, handler)
cancel = bus.on(MyEvent, handler)
# unsubscribe using the cancellation callback returned by .on
cancel()
Another small nicety is that this would let you simplify the cleanup in EventBus.expect
here: https://github.com/browser-use/bubus/blob/main/bubus/service.py#L611-L614
Happy to be the one raising a PR for this as well.
Metadata
Metadata
Assignees
Labels
No labels