The repeat operator

Reactor provides an operator to replay a stream of data. The repeat operator is designed for this purpose. It replays the steam upon receiving the completion event. Let's suppose that we want to output the Fibonacci series twice. We will use the repeat() operator, with 2 as the argument to the repeat() operator:

fibonacciGenerator.take(10).repeat(2).subscribe(t -> {
    System.out.println(t);
}); 

The preceding code generated the stream twice, as shown in the following output. It is important to note that the repeat() operator repeats a stream after receiving the completion event:

Reactor also makes it possible to perform ...

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.