Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would be a real world usage or need of the Rx operator Never?

Why would you ever subscribe to or even create an observable that never yields anything, not even an error, nor completion?

like image 674
Water Cooler v2 Avatar asked Oct 28 '25 07:10

Water Cooler v2


1 Answers

It is a fundamental "atom" in the composition of observable event streams and comes up in a variety of situations - but one of the most common uses for Observable.Never in practice is in writing tests. It easily enables robust checking of timeout logic, for example - and is often combined with the TestScheduler or other virtual time schedulers in test scenarios. If you examine the source code of Rx itself, you find it appears in many unit tests.

like image 86
James World Avatar answered Oct 31 '25 12:10

James World



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!