Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use Mono.never()?

I have read through the Javadocs for the reactor.core.publisher.Mono class From project reactor However I still don't understand what's the point of having the Mono.never() method.

What are some example use cases where one would use Mono.never()?

like image 303
ams Avatar asked Jan 16 '18 02:01

ams


1 Answers

It is very often used in tests (typically to assert timeout behavior), but can also have production usage: some operators take a control Publisher as parameter in various situations where they need an asynchronous external signal to tell them to trigger some behavior. If in some cases you don't want said behavior to trigger, user never().

For instance, windowWhen takes such parameter both for opening and closing windows (the later generated by a Function). Conditionally returning a Mono.never() you could have a window that never closes.

like image 122
Simon Baslé Avatar answered Oct 22 '22 23:10

Simon Baslé