Kotlin for Forge

Kotlin for Forge

70M Downloads

KotlinEventBus cannot determine type of normal lambdas

thedarkcolour opened this issue ยท 1 comments

commented
object ExampleMod {
    init {
        thedarkcolour.kotlinforforge.forge.MOD_BUS.addListener<FMLCommonSetupEvent> { e ->
            // the KotlinEventBus cannot determine the type of this lambda
        }
    }
}
commented

I've done this with a reified type.

inline fun <reified T : Event> IEventBus.listen(
        priority: EventPriority = EventPriority.NORMAL,
        cancelled: Boolean = false,
        crossinline listener: (T) -> Unit) {
    this.addListener(priority, cancelled, T::class.java) { listener(it) }
}