Skip to content

Dev - #1

Open
Beevood wants to merge 3 commits into
mainfrom
dev
Open

Dev#1
Beevood wants to merge 3 commits into
mainfrom
dev

Conversation

@Beevood

@Beevood Beevood commented Jul 31, 2023

Copy link
Copy Markdown
Owner

No description provided.

@Beevood
Beevood requested a review from mikhail-sokolov August 1, 2023 15:46
Comment thread src/main/java/Main.java
List<CompletableFuture<Void>> allFutures = new ArrayList<>();
List<Repo> resultRepos = repos.stream().limit(10).toList();
resultRepos.forEach(repo ->
allFutures.add(client.sendAsync(httpRequestGET(repo.contributeUrl), BODY_HANDLER)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше через collect и собрать список, а не через side effect

Comment thread src/main/java/Main.java
.thenAccept(repo::addContributeNames)
.thenAccept(nothing -> System.out.println("contribute"))
));
CompletableFuture.allOf(allFutures.toArray(new CompletableFuture[0])).join();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

попробуйте список фьюч преобразовать в фьючу со списком значений

private static <T> CompletableFuture<List<T>> getAll(List<CompletableFuture<T>> contributorFutures) {
        return CompletableFuture.allOf(contributorFutures.toArray(CompletableFuture[]::new))
            .thenApply(v -> contributorFutures.stream().map(CompletableFuture::join).collect(Collectors.toList()));
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants