How ReactiveX can serialize asynchronous communications and synthesize results

Asked 1 years ago, Updated 1 years ago, 121 views

Please tell me how ReactiveX can serialize asynchronous communication and synthesize results.

I use rxswift, but I don't tag any specific language because I think it's the same concept.

Currently, functions that return various asynchronous communications as Observable are implemented as follows:
Please tell me how to use them

func requestApiA()->Observable<ResponseA>{/*omitted*/}
func requestApiB(parameterA:ResponseA)->Observable<ResponseB>{/*omitted*/}
US>func requestApiC (parameterA:ResponseA, parameterB:ResponseB) - >Observable<ResponseC>{/*omitted*/}

reactive-programming reactivex

2022-09-30 19:05

1 Answers

Each Observable responds as returning results only once.

let request=requestApiA().flatMap{resAin
    requestApiB(parameterA:resA).flatMap{resBin) 
        requestApiC(parameterA:resA, parameterB:resB) 
    }
}

You can build Observable like this.
The rest will be done as soon as you subscribe.

request.subscribe(...)


2022-09-30 19:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.