nextEvent
inline suspend fun <E : Event> EventChannel<*>.nextEvent(priority: EventPriority = EventPriority.NORMAL, noinline filter: suspend (E) -> Boolean = { true }): E
Content copied to clipboard
挂起当前协程, 直到监听到事件 E 的广播并通过 filter, 返回这个事件实例.
Since
2.10
See also
普通地监听一个事件
挂起当前协程, 并尝试从事件中同步一个值
Parameters
filter
过滤器. 返回 true
时表示得到了需要的实例. 返回 false
时表示继续监听
Content copied to clipboard
挂起当前协程, 直到监听到事件 E 的广播并通过 filter, 返回这个事件实例.
已弃用
该函数相当于 GlobalEventChannel.nextEvent. 不一定需要将所有被弃用的 nextEvent 都换成 GlobalEventChannel.nextEvent
, 请根据情况选择合适的 EventChannel.
See also
普通地监听一个事件
挂起当前协程, 并尝试从事件中同步一个值
Parameters
timeoutMillis
超时. 单位为毫秒. -1
为不限制.
filter
过滤器. 返回 true
时表示得到了需要的实例. 返回 false
时表示继续监听
Throws
kotlinx.coroutines.TimeoutCancellationException
在超时后抛出.