Replies: 2 comments 2 replies
-
The behaviour of StateFlow is conflated. So If there is a delay in |
Beta Was this translation helpful? Give feedback.
2 replies
-
Converting this to a discussion since it's not actually an issue. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Greetings!
Let's assume we have:
interface HomeScreenState {
val isLoading: Boolean
val title: String
val avatar: String
val items: List
val selectedItem: Any?
}
and a method like
fun update() {
_state.isLoading = true
val data = getSomeData()
_state.title = data.title
_state.avatar = data.avatar
_state.items = data.items
_state.selectedItem = data.items.firstOrNull()
}
or
fun update() {
_state.isLoading = true
val data = getSomeData()
_state.apply {
title = data.title
avatar = data.avatar
items = data.items
selectedItem = data.items.firstOrNull()
}
}
How many times would state.collect {} block be called in a view/widget in both cases?
Beta Was this translation helpful? Give feedback.
All reactions