Marek Kubiczek
08/23/2021, 3:46 PMviewLifecycleOwner.lifecycleScope.launch {
  val result = someFlow.first()
  doSomethingInUI(result)
}doSomethingInUIsuspendsomeFlow.first()first()ensureActive()someFlow.onEach {
  doSomnethinginUI(it)
}.launchIn(viewLifecycleOwner.lifecycleScope)onEachephemient
08/23/2021, 7:04 PM.first()CancellationException.launchIn()launch { .collect() }withContext()Marek Kubiczek
08/24/2021, 1:21 PMsomeFlow.onEach {
  nonCancellableDelay()
}.onEach {
  doSomnethinginUI(it)
}.launchIn(viewLifecycleOwner.lifecycleScope)suspend fun nonCancellableDelay() = suspendCoroutine<Unit> {
        Handler(Looper.getMainLooper()).postDelayed(Runnable {
            it.resume(Unit)
        }, 2000)
    }onEachephemient
08/24/2021, 4:04 PMephemient
08/24/2021, 4:05 PMMarek Kubiczek
08/24/2021, 4:08 PMephemient
08/24/2021, 4:10 PMephemient
08/25/2021, 1:37 AMlaunch(lifecycleScope) {
    flow {
        someFlow.collect {
            nonCancellableDelay()
            doSomnethinginUI(it)
            emit(it)
        }
    }.collect()
}ephemient
08/25/2021, 1:38 AMlaunch(lifecycleScope) {
    nonCancellableDelay()
    doSomethingInUi(it)
}ephemient
08/25/2021, 1:42 AMMarek Kubiczek
08/26/2021, 6:08 AM