Can't use the same listener with different filters
- Dominant language
- Python
- Stars
- 14
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
In the events API you can't bind the same function callback to the same class with different filters. The actual behaviour is somewhat surprising:
```
from encore.events.api import EventManager, BaseEvent
em = EventManager()
def listener(event):
print event.source
em.connect(BaseEvent, listener, filter={'source': 1})
em.emit(BaseEvent(source=1)) # prints 1
em.emit(BaseEvent(source=2)) # doesn't fire
em.connect(BaseEvent, listener, filter={'source': 2})
em.emit(BaseEvent(source=1)) # doesn't fire
em.emit(BaseEvent(source=2)) # fires twice, printing 2 each time
```
I think it is reasonable to have the same callback bound with two different filters; however even if it isn't then binding the same function with a different filter should probably remove the old function.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.