If you need step guarantees in multiple mono, and you need to inherit values from each step and batch them, how do you do that wisely?

Viewed 23

In the process of using the project reactor If you need step guarantees in multiple mono, and you need to inherit values from each step and batch them, how do you do that wisely?

Here's the method I'm currently using:

public Mono<Test> someMethod(String id, Test test) {
    return longMonoResult(id)
        .flatMap(aLong -> {
            test.setValue(aLong)
            return booleanMonoResult(aLong)
                .flaMap(aBoolean -> {
                    return longMonoResult2(aBoolean)
                             .map(aLong2 -> test);
                })
        })
}

This looks very poorly readable in my opinion. Also, the more steps are added, the deeper the indentation becomes.

Is there any way to separate the steps?

1 Answers
Related