001/***************************************************
002 * Licensed under MIT No Attribution (SPDX: MIT-0) *
003 ***************************************************/
004
005package org.reactivestreams;
006
007/**
008 * A {@link Publisher} is a provider of a potentially unbounded number of sequenced elements, publishing them according to
009 * the demand received from its {@link Subscriber}(s).
010 * <p>
011 * A {@link Publisher} can serve multiple {@link Subscriber}s subscribed {@link Publisher#subscribe(Subscriber)} dynamically
012 * at various points in time.
013 *
014 * @param <T> the type of element signaled
015 */
016public interface Publisher<T> {
017
018    /**
019     * Request {@link Publisher} to start streaming data.
020     * <p>
021     * This is a "factory method" and can be called multiple times, each time starting a new {@link Subscription}.
022     * <p>
023     * Each {@link Subscription} will work for only a single {@link Subscriber}.
024     * <p>
025     * A {@link Subscriber} should only subscribe once to a single {@link Publisher}.
026     * <p>
027     * If the {@link Publisher} rejects the subscription attempt or otherwise fails it will
028     * signal the error via {@link Subscriber#onError(Throwable)}.
029     *
030     * @param s the {@link Subscriber} that will consume signals from this {@link Publisher}
031     */
032    public void subscribe(Subscriber<? super T> s);
033}