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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.