Publisher And Subscriber

In reactor, if a publisher doesn't have a subscriber, it would not run the code at all.

For example, the following code would not run:

Publisher<Integer> source = Flux.range(1, 10);

For it to run, we need to call a subscribe method:

Flux.range(1, 10).subscribe(System.out::println);

[!note]
In here we cannot call source.subscribe(...) because that will go into the interface of Publisher.subscribe() which takes a Subscriber. We use Flux.subscribe which takes a Consumer