Now that we have discussed Reactor interfaces in detail, let's try to generate a factorial series using Reactor. Given a number, we want to generate a factorial of all numbers less than or equal to the provided number. In number theory, a factorial is described as follows:
Now, let's try to build a factorial stream function that takes a number and attempts to generate a factorial for every number, from 0 to N:
public class FactorialService { Flux<Double> generateFactorial(long number) { Flux<Double> factorialStream = Flux.generate( () -> Tuples.<Long, Double>of(0L, 1.0d), (state, sink) -> { ...