Example of Mono<Void>

5,042 views
Skip to first unread message

Léonard Schneider

unread,
Mar 17, 2017, 4:23:12 PM3/17/17
to reactor-framework
Hi,

I want to implement a Mono that returns nothing, but evaluates asynchronously a side effect function. The only ways to create a Mono<Void> in the API I see are justOrEmpty, which evaluates the arg given or empty that does nothing. I was expecting a Mono.fromConsumer, but there is only a Mono.fromSupplier, which can't be used for Void.

Or should I do (which seems too late): Mono.empty().doOnSuccess(() -> System.println("Hello")) ?

Am I missing something?

Thanks for your help.

BR,


Leo

Léonard Schneider

unread,
Mar 17, 2017, 6:15:30 PM3/17/17
to reactor-framework
I think I've got it.

Mono.create(s -> {
  System.println("Hello");
  s.success();
});


Reply all
Reply to author
Forward
0 new messages