Event Handler
Marks a function as an event handler that should be invoked when an event of the appropriate type is posted to a Bus.
A valid event handler method must:
Be annotated with EventHandler.
Accept exactly one parameter whose type implements Event.
Have a
void/Unitreturn type.
Handlers may be:
instance methods, discovered via Bus.subscribe, or
static methods (
staticin Java or@JvmStaticin Kotlin), discovered via Bus.subscribeStatic.
Invocation Order
When an event is posted, all matching handlers are invoked in order of descending priority. Handlers with the same priority execute in registration order.
Cancellation Interaction
If the event implements Cancelable, delivery of the event to this handler is influenced by:
The EventHandler.runIfCanceled flag, and
The CancelMode supplied to Bus.post.
runIfCanceled
When true, this handler will still receive the event even if it has been canceled — unless the dispatch mode is CancelMode.ENFORCE, in which case no additional handlers run after cancellation.
When false (default), this handler:
receives the event normally when it is not canceled,
receives the event only if the current CancelMode is:
CancelMode.IGNORE, or
CancelMode.RESPECT and the event is not canceled.