-
Notifications
You must be signed in to change notification settings - Fork 18
Open
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels