https://kotlinlang.org logo
Title
a

Andrew Gazelka

06/19/2019, 7:59 PM
any way to write this in a more idiomatic way? (particularly the exception throwing to exit
collect {}
)
s

streetsofboston

06/19/2019, 8:00 PM
Not sure if there is one, but maybe the
Flow
has a
takeUntil
method or something similar. Then you can just do a plain
collect
on that resulting Flow…
There is no
takeUntil
, but there is a
takeWhile
function for a Flow.
Ah.. I see you already use ‘takeWhile’…. hmmmm
b

bezrukov

06/19/2019, 8:54 PM
I think you can use
first
here
👍 1
s

streetsofboston

06/19/2019, 8:55 PM
Also, I’m not sure where
over
in the code-snippet comes from….
a

Andrew Gazelka

06/19/2019, 9:31 PM
I think I’ll just use `first {}`… it is good enough
also
over
does not matter… it is not in the context of the flow
g

gildor

06/20/2019, 6:29 AM
using mutable state is not really idiomatic, why do you need this
last
?
a

Andrew Gazelka

06/20/2019, 7:54 AM
it needed to be used outside of the try{} catch () statement
I don’t think it really related highly to the problem tho
I think
first{}
is good enough
g

gildor

06/20/2019, 8:05 AM
first os good enough
I just worry to set it from collect instead of receive it from first() or other terminal operator