0

I'm new to the whole Spring reactive webflux. My problem is pretty simple. In my addActions() I am trying to get a Mono by calling getCurrentVal(). This works fine. But I need to get the value of that and update a property (submission.stateVal). Then pass call customService.addActions() which returns Mono. Can this be done without using block()?

@Autowired
private CustomService customService;

public Mono<CustomResponse> addActions(String id, String Jwt, Submission submission) {

Mono<String> updatedStateVal = getCurrentStateVal(tpJwt, id);
// submission.setStateVal(updatedStateVal);
// return customService.addActions(id, jwt, submission);


}

private Mono<String> getCurrentVal(String tpJwt, String id) {
        return customService.findById(id, tpJwt)
                .map(r -> r.getStateVal());
}
Lex Li
  • 60,503
  • 9
  • 116
  • 147
John Doe
  • 1,950
  • 9
  • 32
  • 53

1 Answers1

1
return getCurrentStateVal(tpJwt, id)
    .flatMap(s -> {
        submission.setStateVal(s);
        return customService.addActions(id, tpJwt, submission);
    });
iknow
  • 8,358
  • 12
  • 41
  • 68
John Doe
  • 1,950
  • 9
  • 32
  • 53