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