Inside a rest function I'm making a reactive Postgres Db call which is returning a Multi. My intention is to run a complex business logic on Multi and return a new Uni.
@GET
public Uni<Object2> get() {
Multi<Object1> objects = DB.getAll(dbClient);
Uni<HashMap<String, FileTreeNode>> response; // Not sure how to initialize this object without any value
List<Object1> result = new ArrayList<>();
objects.subscribe().with(
object -> result.add(object),
failure -> System.out.println("Failed with " + failure),
() -> {
// Update Uni response object here.
});
return response;
}
Can anyone point me how to create the Uni object and mark it complete inside the business logic so that downstream services notified.