https://kotlinlang.org logo
#compose
Title
# compose
l

Lilly

04/15/2022, 10:03 PM
Would you collect a Flow (not StateFlow) in a composable or collect it in viewmodel and expose it as snapshot (MutableState) field? e.g. your business logic emits a constant flow of progress values to show a ProgressIndicator in UI
m

Michael Paus

04/16/2022, 9:19 AM
Why would you want to do that and make things complicated? Isn’t the progress naturally a state which happens to change over time? What would your ProgressIndicator show before it has received the first progress value. Just using a StateFlow looks much more natural to me. Just my two €ent.
l

Lilly

04/16/2022, 9:37 AM
@Michael Paus StateFlow:
Updates to the value are always conflated.
Conflation:
When a flow represents partial results of the operation or operation status updates, it may not be necessary to process each value, but instead, only most recent ones
Isnt that a problem?
m

Michael Paus

04/16/2022, 10:22 AM
Does it make a difference for a ProgressIndicator? I think not. It always displays the current value of your progress.
l

Lilly

04/16/2022, 11:25 PM
I guess skipping some values is negligibly. I will try it, thanks.
2 Views