Publisher
The publisher holds the data that other components are interested in getting. The publisher will wait until a subscriber who is interested in the data requests n-number of items to be sent, and will only then start sending those items to the subscriber.
Asking for a specific number of items, rather than asking for everything, is called backpressure, and is very important in the Reactive Streams specification. This backpressure lets listeners request only as many items as they can handle at a time, ensuring that the application will not stall or crash.
The interface for Publisher
in Flow, and Reactive Streams looks like this:
@FunctionalInterface public static interface Publisher<T> { public void subscribe(Subscriber<? super T> subscriber); }
You'll notice that it's a functional interface, which can be implemented as a lambda, should you wish.
SubmissionPublisher
Creating a fully functional Publisher can be quite...