You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, Kord events all extend the Event interface, which is open. This is good - it means that frameworks can combine their events with Kord's in their event handling systems trivially.
However, this also creates a problem - when using a when for type checking event objects, the compiler/IDE will be unable to generate an exhaustive list of conditionals. In the case of KordEx, which has functions like this to extract data from Kord events, this means it's very difficult for me to know about changes to Kord's event line up.
To fix this, I propose adding a sealed interface inherited by all Kord event types - perhaps named KordEvent. While this would not solve the problem of generic entity extraction, it would allow framework developers to quickly generate a full list of Kord event types when working with these when blocks.
The text was updated successfully, but these errors were encountered:
I just noticed that this won't be that easy. Right now, Kotlin forces all direct inheritors of a sealed type to be in the same package as the sealed type. However, Kord's events are already placed into different packages.
Currently, Kord events all extend the
Event
interface, which is open. This is good - it means that frameworks can combine their events with Kord's in their event handling systems trivially.However, this also creates a problem - when using a
when
for type checking event objects, the compiler/IDE will be unable to generate an exhaustive list of conditionals. In the case of KordEx, which has functions like this to extract data from Kord events, this means it's very difficult for me to know about changes to Kord's event line up.To fix this, I propose adding a sealed interface inherited by all Kord event types - perhaps named
KordEvent
. While this would not solve the problem of generic entity extraction, it would allow framework developers to quickly generate a full list of Kord event types when working with thesewhen
blocks.The text was updated successfully, but these errors were encountered: