enighma
04/14/2022, 9:05 AMwasyl
04/14/2022, 9:51 AMcombine
for that, or flowA.combine(flowB) { }
enighma
04/14/2022, 9:54 AMwasyl
04/14/2022, 10:01 AMcombine(flowA, flowA.drop(1))
? Although it would seem useful to have a shared flow to not trigger the collection twiceenighma
04/14/2022, 10:02 AMfold/reduce
would make sense.enighma
04/14/2022, 10:02 AMenighma
04/14/2022, 10:03 AMwasyl
04/14/2022, 10:03 AMfun <T> Flow<T>.zipWithPreviousOrNull() = flow {
var prev: T? = null
collect { value ->
emit(prev to value)
prev = value
}
}
but I can’t say if it’s the best solutionenighma
04/14/2022, 10:04 AMephemient
04/14/2022, 10:51 AMenighma
04/14/2022, 11:50 AMStylianos Gakis
04/28/2022, 8:54 AM