Similar to the doOnError life cycle hook, there is the doOnTerminate hook. This is a generic hook that is invoked for on completion and on error stream termination events. Unlike the specific error hook, which provides the exception thrown, this hook does not provide any kind of input. It just executes the lambda provided. It is important to note that the doOnTerminate hook is invoked as soon as we receive termination events. It does not wait for the error callback to be processed. Consider the following code:
@Test public void testDoTerminate() { // Removed for brevity fibonacciGenerator .doOnTerminate(() -> System.out.println("Terminated")) .subscribe(System.out::println,e -> e.printStackTrace() ); }
The preceding ...