takeUntil

@FlowPreview()
fun <T, U> Flow<T>.takeUntil(other: Flow<U>): Flow<T>

Consumes the main source until the other source emits an item or completes.