What I’m trying to do:
Plan intelligently for the case where event handlers are not unique.
When there is exactly one event handler, raise_event()
returns what the handler returns.
What about when the number of handlers != 1? My tests indicate the following:
< 1
?None.
> 1
? The result from whichever handler was called last.
Edit 1: the latter suggests a possible extension: a version of raise_event
that accumulates all results, as a list
(in same order as get_event_handlers
).
Edit 2: a version that yield
s one result at a time, so that we can act on the resulting values, possibly even skipping the remaining calls. (Example: a result that says “Event is officially handled. I’ve taken full responsibility for handling this occurrence.”)
Edit 3: D’oh! Now that we have get_event_handlers
, we can write our own extended versions!