shanky
shanky

Reputation: 801

how would you combine set of mono string in web flux

I have two following methods Mono<Set<String>> researchTeamField = submissionService.findByResearchTeamField() //returns set of string and Mono<Set<String>> reviewerTeamField =submissionService.findByReviewerTeamField() //returns set of reviewer string. I want to combine the result of two set of string into one final mono set string. How can i do it?

Upvotes: 1

Views: 234

Answers (1)

anicetkeric
anicetkeric

Reputation: 636

You can use zip() static method. It merges given monos into a new Mono that will be fulfilled when all of the given Monos have produced an item, aggregating their values as defined by the combinator function.

        Mono<Set<String>> mergeField = Mono.zip(researchTeamField,reviewerTeamField).map(d -> {
            d.getT1().addAll(d.getT2());
            return d.getT1();
        });

Upvotes: 1

Related Questions