Andrew Gazelka
12/28/2020, 12:39 AMshareIn alt which evaluates lazily? i.e.,
aFlow = flow(1,2,3).onEach{ println("A $it") }
shared = aFlow.lazyCache()
shared.take(1).forEach{ println("B $it")}
shared.take(2).forEach{ println("C $it")}
would print “A1 B1 A2 C2"
… or something to that effectTijl
12/28/2020, 7:02 AMSharedFlow with a replay cache? A regular flow can be converted using shareIntseisel
12/28/2020, 7:56 AMshareIn(scope, SharingStarted.LAZY) ? This ensures that the first suscriber gets all emitted values.Tijl
12/28/2020, 8:04 AMreplay flows collecting after that will only get the most recent value (whereas the resulting Flow from asFlow on the ArrayDeque will return all values each collection)Tijl
12/28/2020, 8:06 AMFlow.toList