https://kotlinlang.org logo
Title
p

parth

01/15/2021, 2:27 PM
(crossposting here as well)
m

marstran

01/15/2021, 2:55 PM
I don't think there is such a function in kotlinx.coroutines, but it shouldn't be too hard to implement yourself.
This seems to work, although there might exist a simpler implementation:
fun <T> Flow<T>.skipUntil(flow: Flow<*>): Flow<T> = channelFlow {
    val isSkipping = MutableStateFlow(true)    
    launch { 
    	collect { if (!isSkipping.value) send(it)  }
    }
    
    val signal = flow.first()
    isSkipping.value = false
}
p

parth

01/15/2021, 2:57 PM
ah yup, that makes sense as an impl
thank you!
f

flosch

01/15/2021, 3:24 PM
there is actually a discussion on github about such operators: https://github.com/Kotlin/kotlinx.coroutines/issues/1850
p

parth

01/15/2021, 3:27 PM
ah, i was searching for
skipUntil
, that’s why the issue didn’t show up for me. Thanks!