I am very new to Spring reactive. I have a Mono with me and normal order pojo with me. If pojo has some fields set then I have to do changes in Mono as well and save it in db.

I couldn't find any thing where I will do mono.subscribe(doSomeOperation (monoObject, pojo));

Below is the code that I want to achieve.

void update(Order order){
    Mono<Order> monoOrder = fetchOrder();
    monoOrder.subscribe(updateOrderDetails(monoOrder, order));
}

void updateOrderDetails(Order oldOrder, Order newOrder){
    if(newOrder.getStreet()!=null){
         oldOrder.setStreet(newOrder.getStreet());
         orderRepository.save(oldOrder);
    }
}

Also is there any way to return something from updateOrderDetails and assign it to some variable from where it has been called. I couldn't find anything relative on any online resources.

0 Answers