ZeroMemes / Alpine

A lightweight event system for Java 8+

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Listener Priority Considerations

ZeroMemes opened this issue · comments

Currently, Listener priority for events is only used for sorting Listener instances in ListenerGroup. This works fine if a single event bus is being used without super listeners. However, when an event is posted to an attachable event bus, the attachable bus will dispatch the event to all of it's registered listeners before any of the children receive it, regardless of priority. Similarly, if super listeners are being used, the listeners subscribing to the exact type of an event will receive the event first, regardless of whether a listener of a super type is subscribed with a higher priority.

Ideally, some sort of mechanism for "global" listener priority should exist to solve this issue. The only way I can think of implementing this is through a multi-stage event dispatch, but that would likely require a small number of fixed event priorities, rather than any arbitrary integer value.