I'm building a chain function which the flow is to take result from previous function and loop through each element do some calculation and final return back the original array
I have
func(A) -> Observable<[Object]>
func(B)(Object) -> Observable<Object>
How do we make the chaining like this?
Observable<[Object]> -> [Observable<Object>] -> Observable<[Object]>
You can chain functions with ´flatMap´ operator:
funcA().flatMap{ objects in
Observable.from(objects)
}
.flatMap{ eachObject in
funcB(eachObject)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With