From 8cf51441ad8102d223ae9398c15fedd4134f92fa Mon Sep 17 00:00:00 2001 From: delvh Date: Sun, 20 Sep 2020 14:35:50 +0200 Subject: [PATCH] Add priority section to README --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 1844da4..efe571e 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,23 @@ To include subtypes for an event handler, use the `includeSubtypes` parameter as @Event(includeSubtypes = true) ``` +## Event handler execution order + +Sometimes when using multiple handlers for one event, it might be useful to know in which order they will be executed. +Event Bus provides a mechanism to ensure the correct propagation of events: the `priority`. + +Priority can be set on the `@Event` annotation like that: +```java +@Event(priority=100) +``` + +The default priority for events is `100`. + +**Important:** +Events are dispatched top-down, meaning the event handler with the highest priority will be executed first. + +If no priority is set or multiple handlers have the same priority, the order of execution is undefined. + ## Parameter-less event handlers In some cases an event handler is not interested in the dispatched event instance.