Reputation: 173
I am new with reactive programing and i need help to understeand this scenario.
@autowired
private e;
private Mono<b> method1(list<a> object1){
b object2 = new b();
c object3 = new c();
f object5 = new f();
for (a obj : object1) {
Mono<d> object4 = e.getD(obj.getSomething(), obj.getSomething2());
//I need stop this mapping when a condition is Meet and continue the logic downstream
object4.map(mapper->{
int status= mapper.getStatus();
if(status == 200){
object2.setSomethingElse(mapper.getValue1());
object3.setSomethingElse(mapper.getValue2());
//do something and stop execution
object5.setSomethingElse2(mapper.getValue3());
}
//if that condition is not meet then continue
//more logic doing other set to other values of object2 and 3
});
}
object3.setF(object5);
object2.setB(object3);
return Mono.just(object2);
}
the problem is that when i map into the loop i need to return a response but i dont want do it in that moment i want that the loop ends mapping all values of the dependencies objects and then continue the execution of the method. i hope someone understeand me. I repeat i am new with reactive programing so i dont know if i doing something wrong.
Upvotes: 3
Views: 960
Reputation: 13
Mono.block()
will return the response after the computation is done.
Below code should work.
return Mono.just(object2).block();
Upvotes: 1