subscribe

inline fun <BaseEvent : Event, E : Event> EventChannel<BaseEvent>.subscribe(    crossinline handler: suspend E.(E) -> ListeningStatus,     priority: EventPriority = EventPriority.NORMAL,     concurrency: ConcurrencyKind = ConcurrencyKind.CONCURRENT,     coroutineContext: CoroutineContext = EmptyCoroutineContext): Listener<E>

支持 Kotlin 带接收者的挂起函数的函数引用的监听方式.

suspend fun GroupMessageEvent.onMessage(event: GroupMessageEvent): ListeningStatus {
return ListeningStatus.LISTENING
}

eventChannel.subscribe(GroupMessageEvent::onMessage)

See also


@JvmName(name = "subscribe1")
inline fun <BaseEvent : Event, E : Event> EventChannel<BaseEvent>.subscribe(    crossinline handler: suspend (E) -> ListeningStatus,     priority: EventPriority = EventPriority.NORMAL,     concurrency: ConcurrencyKind = ConcurrencyKind.CONCURRENT,     coroutineContext: CoroutineContext = EmptyCoroutineContext): Listener<E>

支持 Kotlin 挂起函数的函数引用的监听方式.

suspend fun onMessage(event: GroupMessageEvent): ListeningStatus {
return ListeningStatus.LISTENING
}

eventChannel.subscribe(::onMessage)

See also


inline fun <BaseEvent : Event, E : Event> EventChannel<BaseEvent>.subscribe(    crossinline handler: E.(E) -> ListeningStatus,     priority: EventPriority = EventPriority.NORMAL,     concurrency: ConcurrencyKind = ConcurrencyKind.CONCURRENT,     coroutineContext: CoroutineContext = EmptyCoroutineContext): Listener<E>

支持 Kotlin 带接收者的函数的函数引用的监听方式.

fun GroupMessageEvent.onMessage(event: GroupMessageEvent): ListeningStatus {
return ListeningStatus.LISTENING
}

eventChannel.subscribe(GroupMessageEvent::onMessage)

See also


inline fun <BaseEvent : Event, E : Event> EventChannel<BaseEvent>.subscribe(    crossinline handler: (E) -> ListeningStatus,     priority: EventPriority = EventPriority.NORMAL,     concurrency: ConcurrencyKind = ConcurrencyKind.CONCURRENT,     coroutineContext: CoroutineContext = EmptyCoroutineContext): Listener<E>

支持 Kotlin 带接收者的挂起函数的函数引用的监听方式.

fun onMessage(event: GroupMessageEvent): ListeningStatus {
return ListeningStatus.LISTENING
}

eventChannel.subscribe(::onMessage)

See also