We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have an existing async called wrapped inside a Try and working with Futures.sequence
e.g.
List<CompletableFuture<Try<Foo>>> requests = [...] CompletableFuture<List<Try<Baz>>> items = Futures.sequence(requests); List<Try<Baz>> result = items.join() .stream() .map(try -> myFunction(try)) .collect(Collectors.toList()) ... private Try<Baz> myFunction(Try<Foo> fooTry) { return fooTry.flatMap(foo -> Try.ofFailable(() -> process(foo))); }
is there an example/support for two async calls? such as
List<CompletableFuture<Try<Foo>>> requests1 = [...] List<CompletableFuture<Try<Bar>>> requests2 = [...] // requests1.size(), requests2.size() are the same value List<CompletableFuture<Try<Baz>>> results = new ArrayList<>(); for (int i = 0; i < items1.size(); i++) { CompletableFuture<Try<Baz>> combined = items1.get(i).thenCombine(items2.get(i), (fooTry, barTry) -> myFunction(fooTry, barTry)); results.add(combined); } List<Try<Baz>> results = results.stream().map(CompletableFuture::join).collect(Collectors.toList()); ... private Try<Baz> myFunction(Try<Foo> fooTry, Try<Bar> barTry) { return fooTry.flatMap(foo -> barTry.flatMap(bar -> Try.ofFailable(() -> process(foo, bar)))); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have an existing async called wrapped inside a Try and working with Futures.sequence
e.g.
is there an example/support for two async calls? such as
The text was updated successfully, but these errors were encountered: