Why does `combine(flows, transform)` not call `tra...
# flow
a
Why does
combine(flows, transform)
not call
transform
if
flows
is empty? Is that intended? Seems like it would be more natural to call it with an empty array.
e
I don't think so. the transform should only be called when there are emissions, and there are none here
a
My use-case is that I have a list of flows of
Int
, and I need to return a flow of their sum.
combine(flows, Array<Int>::sum)
seems like an intuitive solution that fails when
flows
is empty.
e
Copy code
combine(List(n) { flowOf(*Array(m) { 0 }) }, transform)
the way I see it: in general, this can call
transform
anywhere in
n..n*(m-1)+1
times. when
n=0
, 0 times is a reasonable ourcome
a
On the other hand
Copy code
combine(List(n){ flowOf(0) }, transform)
calls transform exactly once for every value of
n
except
0
n
Copy code
combine(List(n){ flowOf(0) }, transform)
also receives emitted most recent values (which is what it operates on) for every
n
except
0
.
e
Copy code
combine(List(n) { flowOf() }, transform)
calls
transform
0 times for any value of
n
, including 0