Marcin Wisniowski
01/02/2024, 6:23 PMcombine(flowA, flowB) { a, b -> a to b }.collect { (a, b) -> println("$a, $b") }
I'm looking to remove the "useless" transform step that the combine
function requires.phldavies
01/02/2024, 6:44 PMUnit
and .collect()
?
combine(flowA, flowB) { a, b -> println("$a, $b") }.collect()
phldavies
01/02/2024, 6:45 PMKlitos Kyriacou
01/02/2024, 6:49 PMcombineTransform
be what you're looking for?ephemient
01/02/2024, 6:50 PMcombineTransform
is basically the same as combine
with a lambda for this use case, although you can emit nothing which I guess is slightly less workMarcin Wisniowski
01/02/2024, 10:30 PMcombineTransform
here in a way that would make it shorter.ephemient
01/02/2024, 10:31 PMcombineTransform(flowA, flowB) { a, b -> println("$a, $b") }.collect()
same as Phil's suggestion, but it skips the discarded emissionsMarcin Wisniowski
01/02/2024, 10:33 PMcombineTransform
makes me manually specify types so it becomes combineTransform<TypeA, TypeB, Unit>(flowA, flowB) { a, b -> println("$a, $b") }.collect()
Marcin Wisniowski
01/02/2024, 10:34 PMcombine
the type parameters are inferred correctly.ephemient
01/02/2024, 10:36 PM.combineTransform<_, _, Nothing> { a, b ->
it is longer, but it more clearly marks that the transform doesn't actually produce any outputMarcin Wisniowski
01/02/2024, 10:36 PM