``` vuserChannel .filterNotNull() ...
# coroutines
d
Copy code
vuserChannel
        .filterNotNull()
        .map(CommonPool) { it.userName }
        .consumeEach(UI) { user_name.text = it }
e
Makes sense. But what is the context of this code? Where you tend to write this code? Can you share a larger price in gist? Can you share the whole project?
a
I guess it would make sense if this code is inside a parent coroutine. If this is the case, this coroutines can take the UI context and there's no need to define another one for consumeEach because it's gonna be dispatched on UI context anyway
d
1. I have
View
and
ViewModel
. 2.
ViewModel
have
userChannel
which emits
User
whenever it changes. 3.
View
consume all events from
userChannel
. Because
map
is
heavy
operation I wan’t to execute it on non-ui thread, after that I want to consume all events on ui-thread because I touch views.
So it’s just a sugar syntax instead of:
Copy code
launch(UI) {
    userChannel.map(CommonPool) { it.userName }
        .consumeEach { user_name.text = it }
}
I would like to avoid those braces.