mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-09 19:50:27 +08:00
Remove listener when job is completed
This commit is contained in:
parent
074236ceda
commit
df1fbbe236
@ -26,7 +26,12 @@ val EventLogger: MiraiLoggerWithSwitch = DefaultLogger("Event").withSwitch(false
|
||||
|
||||
@MiraiInternalAPI
|
||||
fun <L : Listener<E>, E : Event> KClass<out E>.subscribeInternal(listener: L): L {
|
||||
this.listeners().addLast(listener)
|
||||
with(this.listeners()) {
|
||||
addLast(listener)
|
||||
listener.invokeOnCompletion {
|
||||
this.remove(listener)
|
||||
}
|
||||
}
|
||||
return listener
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user