edvin / tornadofx

Lightweight JavaFX Framework for Kotlin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EventBus.fire does not check for listeners of superclass types

comp500 opened this issue · comments

I'm not sure if this is intended behaviour, but EventBus.fire does not check for listeners of superclass types - so if you create an event class and then subclass it, subscribers of the superclass event won't be notified when firing the subclass event.

I think it would be beneficial for extensibility and reusability to support notifying superclass subscribers; it doesn't seem like an intentional design choice to not do so.

An alternative to checking the superclasses could be specifying the event type as a reified generic/parameter in EventBus.fire, rather than retrieving the KClass through reflection; this would be easier to implement, though less intuitive than notifying superclass subscribers.