collectIn

fun <T> Flow<T>.collectIn(scope: CoroutineScope, action: suspend (T) -> Unit): Job

Launches collection of the flow in scope, invoking action for each value, and returns the Job.

Shorthand for scope.launch { collect(action) }. Collection stops when the returned job or scope is cancelled; an upstream failure fails the job through the scope.