Open skynyrd opened 6 years ago
Hi, @skynyrd !
You can do something like this:
def listener(myevent):
myevent.returnvalue = 33333
myevent = mediator.dispatch(MyEvent())
print(myevent.returnvalue)
return it from dispatch method
What if there are multiple listeners?
Hey @Kilte,
Indeed I could pass return value to the event itself as you suggested, but I think this time event is becoming kinda dto and single responsibility is broken.
And yes my suggestion works for command/command handler usage but fails for events (multiple listeners) Maybe list of a tuple of the result and the listener name can be returned ama it's a bit overkill.
Thinking about that :)
@ghost @skynyrd event should not have a return value by definition, it is a fact that already happened in the system. Thus having a distinction between commands and events is necessary here. A command should have a return value imho.
Hi, first I appreciate your simple and useful library.
I tried to use mediator in my Sanic app and I want to get the returned value from listener.
For example:
My listener:
I can fork the repo and return it from dispatch method but I wonder why you are returning event, and may be I am missing something here.
Thanks,