Lifecycle hooks

The publisher-subscriber communication generates events throughout the lifecycle of a Reactive Stream. Reactor provides corresponding lifecycle methods that can be used to hook custom logic to each of the said events, as shown in the following table:

Event
Method
Subscribe event doOnSubscribe
Request event, for N items from the subscriber doOnRequest
Value event, for all generated values doOnNext
Error event, for any error by the publisher doOnError
Completion event doOnCompletion
Cancel event, for cancellation by the subscriber doOnCancel

 

In addition to the preceding methods, there are the following methods:

  • doOnEach: This method is executed for all publisher events raised in the stream processing. ...

Get Hands-On Reactive Programming with Reactor now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.