pablisco
01/24/2022, 2:59 PMflow.flatMapLatest {
flow {
emit("a")
emit("b")
emitAll(otherFlow())
}
}
the same as this?
flow.transformLatest {
emit("a")
emit("b")
emitAll(otherFlow())
}
They seem to do the same on paper (minus the extra flow object), however, is there anything that using flatMapLatest
will do that transformLatest
doesn’t? 🙂Joffrey
01/24/2022, 3:04 PMflatMapLatest
literally calls transformLatest
under the hood, and simply emits all items from the flow returned by the lambda. So I don't believe there is any real difference. I'd say it's mostly a matter of expressing better what the code does, and avoiding the extra flowflatMapLatest
if you need to do some extra stuff before creating the new flow for a given element of the source flowpablisco
01/24/2022, 3:17 PM