Torkel Velure
Oct 21, 2021

--

This is awesome and I'm using channels for events now!

With Lifecycle 2.4 you no longer need these extensions though, you can do the same thing with:

```

fun <T> Flow<T>.observe(owner: LifecycleOwner, collector: (T) -> Unit) {

owner.lifecycleScope.launch {

owner.repeatOnLifecycle(Lifecycle.State.STARTED) {

this@observe.collect {

collector(it)

}

}

}

}

```

--

--

Responses (1)