subscribeAlways
inline fun <E : Event> subscribeAlways(coroutineContext: CoroutineContext = EmptyCoroutineContext, concurrency: ConcurrencyKind = CONCURRENT, priority: EventPriority = EventPriority.NORMAL, noinline handler: suspend E.(E) -> Unit): Listener<E>
创建一个事件监听器, 监听事件通道中所有 E 及其子类事件. 每当 事件广播 时, handler 都会被执行.
可在任意时候通过 Listener.complete 来主动停止监听.
Return
监听器实例. 此监听器已经注册到指定事件上, 在事件广播时将会调用 handler
Parameters
concurrency
并发类型默认为 CONCURRENT
coroutineContext
在 defaultCoroutineContext 的基础上, 给事件监听协程的额外的 CoroutineContext
priority
处理优先级, 优先级高的先执行
See also
获取更多说明
fun <E : Event> subscribeAlways(eventClass: KClass<out E>, coroutineContext: CoroutineContext = EmptyCoroutineContext, concurrency: ConcurrencyKind = CONCURRENT, priority: EventPriority = EventPriority.NORMAL, handler: suspend E.(E) -> Unit): Listener<E>
See also
fun <E : Event> subscribeAlways(eventClass: <Error class: unknown class><out E>, coroutineContext: CoroutineContext = EmptyCoroutineContext, concurrency: ConcurrencyKind = CONCURRENT, priority: EventPriority = EventPriority.NORMAL, handler: <Error class: unknown class><E>): Listener<E>
Java API. 查看 subscribeAlways 获取更多信息.
eventChannel.subscribeAlways(GroupMessageEvent.class, (event) -> { });
Content copied to clipboard