Marc Knaup
08/09/2020, 1:49 PMFlow.toList()
closes the Flow but Stream.toList()
doesn’t close the Stream.
Is that inconsistency intentional?Dominaezzz
08/09/2020, 6:21 PMMarc Knaup
08/09/2020, 6:30 PM.toList()
.Dominaezzz
08/09/2020, 6:37 PMtoList()
) it must be completely collected (or cancelled). With this rule, a Flow
can hold on to resources once collection starts and release them upon completion/cancellation.
Streams on the other hand, don't have to be completed after iteration begins, so the close method is used to signal a cancellation (I guess).
Disclaimer: Haven't properly used Streams.Marc Knaup
08/09/2020, 6:38 PMtoList()
on each.Dominaezzz
08/09/2020, 6:45 PMtoList()
, I thought it was a special java function.
Can you point me to the toList()
function? I don't think it's the same function for both objects.Marc Knaup
08/09/2020, 6:46 PMtoList()
will close resources, in the other case it won’t.
I think it’s a problem with Streams, but because they’re so similar and both coming from Kotlin, it’s still confusing.