tornadofx2 icon indicating copy to clipboard operation
tornadofx2 copied to clipboard

Class Hierarchy for FXEvents

Open xeruf opened this issue 3 years ago • 0 comments

I would like to have a group of FXEvents to which I can subscribe all at once and then selectively filter out the specific events, e.g.:

sealed class GameUpdateEvent: FXEvent()
class GameReadyEvent: GameUpdateEvent()
data class NewGameState(val gameState: IGameState): GameUpdateEvent()
data class GamePausedEvent(val paused: Boolean): GameUpdateEvent()
data class GameOverEvent(val result: GameResult): GameUpdateEvent()

subscribe<GameUpdateEvent> { event ->
    // check event
}

But from what it seems, the subscribe class has to match exactly, no subclasses. This is not so wild for the subscription, but really annoying if I then want to remove all subscriptions of all subclasses.

xeruf avatar May 27 '21 16:05 xeruf