waitMatchesWithTimeout

inline suspend fun <T : Event> EventListener.waitMatchesWithTimeout(timeout: Duration, priority: Short = 0, predicate: Predicate<T>): T?

Wait an event of type T which matches given predicate. If the timeout is exceeded, return null.

This is exactly a shortcut of:

withTimeoutOrNull(timeout) { waitMatches(priority, predicate) }

Parameters

timeout

The timeout duration.

priority

The priority of the event hook.

predicate

The predicate to match the event. If it throws a Throwable, the continuation will be resumed with Result.failure.