Why `Flow<T>.collectWhile(predicate)` is in...
# coroutines
a
Why
Flow<T>.collectWhile(predicate)
is internal in kotlinx.coroutines.flow ? It could be useful to suspend a coroutine till value matches some predicate. Is
Flow<T>.first(predicate): T
considered to be used (as it utilizes the collectWhile) or something else to be used?
l
collectWhile is equivalent to transformWhile & emit + collect. Now that's not what you need as Roman just commented
e
How is this different than
filter
? Your collector is suspended while it doesn't receive new values
e
I use
first
to suspend until predicate. Looks really nice in code. Like
flow.first { it > 0 }
a
Ah, thanks! Very much surprised Roman sir replied 😄😃🙂