mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-08 17:20:11 +08:00
Add top-level fun for subscribeAll
This commit is contained in:
parent
a9b3ecf5ea
commit
8e323644ab
@ -60,6 +60,15 @@ fun <E : Event> KClass<E>.subscribeAll(listeners: ListenerBuilder<E>.() -> Unit)
|
||||
ListenerBuilder<E> { this.subscribeInternal(it) }.apply(listeners)
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听一个事件. 可同时进行多种方式的监听
|
||||
* @see ListenerBuilder
|
||||
*/
|
||||
inline fun <reified E : Event> subscribeAll(noinline listeners: ListenerBuilder<E>.() -> Unit) {
|
||||
ListenerBuilder<E> { this.subscribeInternal(it) }.apply(listeners)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 监听构建器. 可同时进行多种方式的监听
|
||||
*
|
||||
@ -99,4 +108,4 @@ inline class ListenerBuilder<out E : Event>(
|
||||
|
||||
|
||||
fun once(block: suspend (E) -> Unit) = handler { block(it); ListeningStatus.STOPPED }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user