some change on TimerEvents.

This commit is contained in:
dalbodeule
2024-07-30 23:00:29 +09:00
parent a9ee40e936
commit 99ec9ba7a0
3 changed files with 11 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ package space.mori.chzzk_bot.common.events
interface Event
interface EventHandler<E: Event> {
suspend fun handle(event: E)
fun handle(event: E)
}
object EventDispatcher {
@@ -13,7 +13,7 @@ object EventDispatcher {
handlers.computeIfAbsent(eventClass) { mutableListOf() }.add(handler)
}
suspend fun <E : Event> dispatch(event: E) {
fun <E : Event> dispatch(event: E) {
handlers[event::class.java]?.forEach { (it as EventHandler<E>).handle(event) }
}
}