16 lines
465 B
Kotlin
16 lines
465 B
Kotlin
package fr.username404.snowygui
|
|
|
|
interface EventSnowy {
|
|
val type: String
|
|
fun <T> fire(vararg args: T?) {
|
|
useKey(type).forEach {
|
|
it(args)
|
|
}
|
|
}
|
|
companion object {
|
|
fun useKey(key: String): MutableSet<argsLambda> { return eventMap.getOrPut(key, ::mutableSetOf) }
|
|
private val eventMap: MutableMap<String, MutableSet<argsLambda>> = mutableMapOf()
|
|
}
|
|
}
|
|
|
|
internal typealias argsLambda = (args: Array<*>) -> Unit |