Kotlin Flow have pipe like rxjs sample? <https://...
# getting-started
a
Kotlin Flow have pipe like rxjs sample? https://rxjs.dev/api/operators/sample
s
As far as I understand it,
pipe
is used to avoid nesting lots of operators. Kotlin uses extension functions for Flow operators, which solves the same problem, so there's no need for a
pipe
equivalent.
By nested operators, I mean something like the example in the docs you linked to:
Copy code
op4()(op3()(op2()(op1()(obs))))
In Kotlin, it would be more like
Copy code
flow.op1().op2().op3().op4()
a
sorry, I don’t have a problem with the extended way of writing Flow. I want to achieve the effect of the rxjs
sample
in kotlin Flow
s
Oh I see, you were asking about sample rather than pipe
I misunderstood your question!
a
Sorry, my native language is not English😣
s
I think you could achieve the behaviour of
sample
by using
combine
or maybe
combineLatest
a
Flow also has the sample method, but it doesn’t seem to be the same as the sample operator in rxjs
👍 1
two flow with one list solved😄