I want to create a helper method that can wrap/convert just any sync method call into an async Mono
.
The following is close, but shows an error:
Required type: Mono <T>
Provided: Mono<? extends Callable<? extends T>>
This is my code:
public <T> Mono<T> wrapAsync(Callable<? extends T> supplier) {
return Mono.fromCallable(() -> supplier)
.subscribeOn(Schedulers.boundedElastic());
}
public void run() {
Mono<Boolean> mono = wrapAsync(() -> syncMethod());
}
private Boolean mySyncMethod() {
return true; //for testing only
}