first

suspend fun <T> Flow<T>.first(): T(source)

The terminal operator that returns the first element emitted by the flow and then cancels flow's collection. Throws NoSuchElementException if the flow was empty.


suspend fun <T> Flow<T>.first(predicate: suspend (T) -> Boolean): T(source)

The terminal operator that returns the first element emitted by the flow matching the given predicate and then cancels flow's collection. Throws NoSuchElementException if the flow has not contained elements matching the predicate.