How to chain calls, depending on result ?
See original GitHub issueHello,
In my webapp, I have to chain two async calls : The first call gives me a list of dog ids. The second call gives me a Dog (found by its id).
In my code, i’d like to write something like :
final Observable<RxMessage<String>> observable1 = asyncCallForDogIds(..);
final List<Dog> dogs = new ArrayList<>();
observable1.subscribe(
// onNext
(RxMessage<String> message) -> {
final String id = readId(message);
final Observable<RxMessage<String>> observable2 = someAsyncCallForOneDogId(id, ..);
final Dog dog = readFromSomeMessage2(...);
dogs.add(dog);
},
// onError
(Throwable err) -> error(err, ..),
// onCompleted
() -> resume(dogs, ..));
What would be the best way to do that ? Th.
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Promises chaining - The Modern JavaScript Tutorial
The idea is that the result is passed through the chain of .then handlers. Here the flow is: The initial promise resolves in...
Read more >How to proper chain promises calls that depend on one ...
Basically, it's a chain of request call, each one based on the result of the previous call. The problem is that I have...
Read more >Chain HTTP Requests in React Using Promises - Pluralsight
Chaining Requests Using Promises You can easily complete this feature by using the Fetch and Promise APIs. The below code is an example...
Read more >Optional chaining (?.) - JavaScript - MDN Web Docs
The optional chaining ( ?. ) operator accesses an object's property or calls a function. If the object is undefined or null ,...
Read more >Chaining tasks using continuation tasks | Microsoft Learn
Learn to chain task by using continuation tasks in .NET. A continuation task is an ... Result property, which does block the calling...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you want to handle errors for each call you put the
onErrorResumeNext
or similar handlers on each of the async calls.You want
flatMap
so roughly: