pymitter
pymitter copied to clipboard
Support async callable classes
Hello! I'd like to use pymitter with async callable classes, like this.
class EventHandler:
def __init__(self, dep1, dep2): # Injected dependencies.
self.dep1 = dep1
self.dep2 = dep2
async def __call__(self, arg):
...
ee.on("event", EventHandler(dep1, dep2))
It's not possible right now, due to the way pymitter
checks if an event handler is async using asyncio.iscoroutinefunction
. I've added another check that works with such callables. pyee
supports this usecase, but sadly it lacks wildcard dispatching.