https://kotlinlang.org logo
#coroutines
Title
# coroutines
y

yschimke

05/31/2023, 10:55 AM
If I have a flow of some completion progress, that doesn't ever self terminate. Say
flowOf(0.0, 0.5, 0.99, 1.0, 1.0, 1.0, 1.0, 1.0, ...)
Is there a nice operator to terminate after the first complete signal? Effectively
flowOf(0.0, 0.5, 0.99, 1.0)
, results are actually a data class with other interesting data, not a float.
y

yschimke

05/31/2023, 10:57 AM
Sure, but a simple conditional check (it != 1.0) will omit the first 1.0 value.
I want one more after it.
I'm about to write my own stateful operator for this.
y

yschimke

05/31/2023, 11:37 AM
Thanks, transformWhile wasn't obvious, but great idea.