I'm probably missing something obvious... :rubber_...
# coroutines
d
I'm probably missing something obvious... rubber duck
I guess I'll have to use
toList().all { it == ActionStatus.SUCCESS }
... 🙃
t
You were really close to the answer ! You can write your own
Flow.all
this way:
Copy code
suspend inline fun <T> Flow<T>.all(crossinline predicate: (T) -> Boolean): Boolean =
    fold(true) { result, element -> result && predicate(element) }
d
Thanks, it works now! I originally tried doing acc && true in the first block... but AS suggested to simplify it to
acc
only... was that my mistake?
t
To me, the problem was that you passed
false
as the initial value, so that
acc
is always false even if
value == ActionStatus.SUCCESS
Replacing
fold(false)
with
fold(true)
in your code should work
👍🏼 1