Reputation: 2609
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]>
Upvotes: 5
Views: 7946
Reputation: 2326
You can chain functions with ´flatMap´ operator:
funcA().flatMap{ objects in
Observable.from(objects)
}
.flatMap{ eachObject in
funcB(eachObject)
}
Upvotes: 16