if I have a Sequence from buildSequence, is there ...
# coroutines
r
if I have a Sequence from buildSequence, is there a way to collect all the elements it's already yielded and not care about anything else
d
Why not just... stop iterating through the sequence.
r
It's going to be an infinite sequence. in most cases i'm just going to care about the most recent elements its yielded but i do need a history which is why im not going with a channel
d
Yeah, break out of the iteration or use
take
.
Hard to advise without example code.
Also,
Sequence
doesn't store history. It's basically a blocking
Channel
.
a
If you require history, maybe you could make something that subscribes to the sequence and appends it to a list. Then you can get the entire list whenever you want
d
Yeah, you can use an iterator delegate.