https://kotlinlang.org logo
Title
m

myanmarking

08/28/2019, 2:13 PM
i tried onStart but obviously, it still is debounced
v

Vlad

08/28/2019, 2:20 PM
even if the onStart is applied on the debounced flow?
i.e
flow.debounce().onStart{}
m

myanmarking

08/28/2019, 2:21 PM
yes
it doesn't work like rxjava 😛 that was my assumption. and it doesn't
v

Vlad

08/28/2019, 2:35 PM
runBlockingTest {
        val input = BroadcastChannel<Int>(1)
        val flow = input.asFlow().debounce(1000).onStart { emit(100) }

        val results = mutableListOf<Int>()
        launch{
            flow.collect { results.add(it) }
        }

        input.offer(1)

        assertThat(results).isEqualTo(listOf(100))

        advanceTimeBy(1000)
        assertThat(results).isEqualTo(listOf(100, 1))
}
This test is passing. Am I missing something?
m

myanmarking

08/28/2019, 2:46 PM
yes, you right it is working
maybe i placed onStart in the wrong place, idk. gona check it better and let u know
thanks
👍 1