edvin / tornadofx2

TornadoFX 2.0
Apache License 2.0
156 stars 41 forks source link

Class Hierarchy for FXEvents #38

Open xeruf opened 3 years ago

xeruf commented 3 years ago

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.