Rana_S
Rana_S

Reputation: 1550

Merge Flux result and return Flux

I have a List<Event> and for each Event, I need to set EventDocument. I get Flux<EventDocument>from an api. I need to map correct EventDocument to Event and return Flux<Event>.

Api call to get EventDocument

private Flux<EventDocument> getDocuments(List<Long> eventIds) {
    String url = this.documentServiceUrl + "/events?eventId=" + eventIds;
    return getWebClient()
            .post()
            .uri(url)
            .body(eventIds, List.class)
            .retrieve()
            .bodyToFlux(EventDocument.class)
            .log()
            .onErrorResume(error -> Flux.empty());
}

How do I map results from above to correct Event and return Flux<Event>?

Upvotes: 0

Views: 365

Answers (1)

Semyon Kirekov
Semyon Kirekov

Reputation: 1442

Flux<EventDocument> eventDocuments = ...;
Flux<Event> events = eventDocuments.map(mapToEventFunction);

Upvotes: 2

Related Questions