Class Publisher<T>
- java.lang.Object
-
- io.servicetalk.concurrent.api.Publisher<T>
-
- Type Parameters:
T- Type of items emitted.
- Direct Known Subclasses:
GroupedPublisher,SubscribablePublisher,TestPublisher
public abstract class Publisher<T> extends java.lang.ObjectAn asynchronous computation that produces 0, 1 or more elements and may or may not terminate successfully or with an error.How to subscribe?
This class does not provide a way to subscribe using aPublisherSource.Subscriberas such calls are ambiguous about the intent whether the subscribe is part of the same source (a.k.a an operator) or it is a terminal subscribe. If it is required to subscribe to a source, then asource adaptercan be used to convert to aPublisherSource.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPublisher()New instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Publisher<T>afterCancel(java.lang.Runnable onCancel)Invokes theonCancelRunnableargument afterCancellable.cancel()is called forPublisherSource.Subscriptions of the returnedPublisher.Publisher<T>afterFinally(TerminalSignalConsumer doFinally)Invokes the corresponding method onafterFinallyTerminalSignalConsumerargument after any of the following terminal methods are called:PublisherSource.Subscriber.onComplete()- invokesTerminalSignalConsumer.onComplete()PublisherSource.Subscriber.onError(Throwable)- invokesTerminalSignalConsumer.onError(Throwable)Cancellable.cancel()- invokesTerminalSignalConsumer.cancel()forPublisherSource.Subscriptions/PublisherSource.Subscribers of the returnedPublisher.Publisher<T>afterFinally(java.lang.Runnable doFinally)Invokes theafterFinallyRunnableargument after any of the following terminal methods are called:PublisherSource.Subscriber.onComplete()PublisherSource.Subscriber.onError(Throwable)Cancellable.cancel()forPublisherSource.Subscriptions/PublisherSource.Subscribers of the returnedPublisher.Publisher<T>afterOnComplete(java.lang.Runnable onComplete)Invokes theonCompleteRunnableargument afterPublisherSource.Subscriber.onComplete()is called forPublisherSource.Subscribers of the returnedPublisher.Publisher<T>afterOnError(java.util.function.Consumer<java.lang.Throwable> onError)Invokes theonErrorConsumerargument afterPublisherSource.Subscriber.onError(Throwable)is called forPublisherSource.Subscribers of the returnedPublisher.Publisher<T>afterOnNext(java.util.function.Consumer<? super T> onNext)Invokes theonNextConsumerargument afterPublisherSource.Subscriber.onNext(Object)is called forPublisherSource.Subscribers of the returnedPublisher.Publisher<T>afterOnSubscribe(java.util.function.Consumer<? super PublisherSource.Subscription> onSubscribe)Invokes theonSubscribeConsumerargument afterPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is called forPublisherSource.Subscribers of the returnedPublisher.Publisher<T>afterRequest(java.util.function.LongConsumer onRequest)Invokes theonRequestLongConsumerargument afterPublisherSource.Subscription.request(long)is called forPublisherSource.Subscriptions of the returnedPublisher.Publisher<T>afterSubscriber(java.util.function.Supplier<? extends PublisherSource.Subscriber<? super T>> subscriberSupplier)Creates a newPublisherSource.Subscriber(via thesubscriberSupplierargument) for each new subscribe and invokes all thePublisherSource.Subscribermethods after thePublisherSource.Subscribers of the returnedPublisher.Publisher<T>afterSubscription(java.util.function.Supplier<? extends PublisherSource.Subscription> subscriptionSupplier)Creates a newPublisherSource.Subscription(via thesubscriptionSupplierargument) for each new subscribe and invokes all thePublisherSource.Subscriptionmethods after thePublisherSource.Subscriptions of the returnedPublisher.Publisher<T>beforeCancel(java.lang.Runnable onCancel)Invokes theonCancelRunnableargument beforeCancellable.cancel()is called forPublisherSource.Subscriptions of the returnedPublisher.Publisher<T>beforeFinally(TerminalSignalConsumer doFinally)Invokes the corresponding method onbeforeFinallyTerminalSignalConsumerargument before any of the following terminal methods are called:PublisherSource.Subscriber.onComplete()- invokesTerminalSignalConsumer.onComplete()PublisherSource.Subscriber.onError(Throwable)- invokesTerminalSignalConsumer.onError(Throwable)Cancellable.cancel()- invokesTerminalSignalConsumer.cancel()forPublisherSource.Subscriptions/PublisherSource.Subscribers of the returnedPublisher.Publisher<T>beforeFinally(java.lang.Runnable doFinally)Invokes thebeforeFinallyRunnableargument before any of the following terminal methods are called:PublisherSource.Subscriber.onComplete()PublisherSource.Subscriber.onError(Throwable)Cancellable.cancel()forPublisherSource.Subscriptions/PublisherSource.Subscribers of the returnedPublisher.Publisher<T>beforeOnComplete(java.lang.Runnable onComplete)Invokes theonCompleteRunnableargument beforePublisherSource.Subscriber.onComplete()is called forPublisherSource.Subscribers of the returnedPublisher.Publisher<T>beforeOnError(java.util.function.Consumer<java.lang.Throwable> onError)Invokes theonErrorConsumerargument beforePublisherSource.Subscriber.onError(Throwable)is called forPublisherSource.Subscribers of the returnedPublisher.Publisher<T>beforeOnNext(java.util.function.Consumer<? super T> onNext)Invokes theonNextConsumerargument beforePublisherSource.Subscriber.onNext(Object)is called forPublisherSource.Subscribers of the returnedPublisher.Publisher<T>beforeOnSubscribe(java.util.function.Consumer<? super PublisherSource.Subscription> onSubscribe)Invokes theonSubscribeConsumerargument beforePublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is called forPublisherSource.Subscribers of the returnedPublisher.Publisher<T>beforeRequest(java.util.function.LongConsumer onRequest)Invokes theonRequestLongConsumerargument beforePublisherSource.Subscription.request(long)is called forPublisherSource.Subscriptions of the returnedPublisher.Publisher<T>beforeSubscriber(java.util.function.Supplier<? extends PublisherSource.Subscriber<? super T>> subscriberSupplier)Creates a newPublisherSource.Subscriber(via thesubscriberSupplierargument) on each call to subscribe and invokes all thePublisherSource.Subscribermethods before thePublisherSource.Subscribers of the returnedPublisher.Publisher<T>beforeSubscription(java.util.function.Supplier<? extends PublisherSource.Subscription> subscriptionSupplier)Creates a newPublisherSource.Subscription(via thesubscriptionSupplierargument) on each call to subscribe and invokes all thePublisherSource.Subscriptionmethods before thePublisherSource.Subscriptions of the returnedPublisher.<BC extends BufferStrategy.Accumulator<T,B>,B>
Publisher<B>buffer(BufferStrategy<T,BC,B> strategy)<R> Single<R>collect(java.util.function.Supplier<? extends R> resultFactory, java.util.function.BiFunction<? super R,? super T,R> collector)Collects all items emitted by thisPublisherinto a single item.CompletablecompletableOrError()Converts thisPublisherto aCompletable.Publisher<T>concat(Completable next)Publisher<T>concat(Publisher<? extends T> next)Publisher<T>concat(Single<? extends T> next)static <T> Publisher<T>defer(java.util.function.Supplier<? extends Publisher<? extends T>> publisherSupplier)Defers creation of aPublishertill it is subscribed.static <T> Publisher<T>empty()Creates a newPublisherthat completes when subscribed without emitting any item to itsPublisherSource.Subscriber.static <T> Publisher<T>failed(java.lang.Throwable cause)Creates a newPublisherthat terminates itsPublisherSource.Subscriberwith an error without emitting any item to it.Publisher<T>filter(java.util.function.Predicate<? super T> predicate)Filters items emitted by thisPublisher.Single<T>firstOrElse(java.util.function.Supplier<T> defaultValueSupplier)Single<T>firstOrError()Ensures that thisPublisheremits exactly a singlePublisherSource.Subscriber.onNext(Object)to itsPublisherSource.Subscriber.CompletableflatMapCompletable(java.util.function.Function<? super T,? extends Completable> mapper)Map each element of thisPublisherinto aCompletableand flatten all signals such that the returnedCompletableterminates when all mappedCompletables have terminated successfully or any one of them has terminated with a failure.CompletableflatMapCompletable(java.util.function.Function<? super T,? extends Completable> mapper, int maxConcurrency)Map each element of thisPublisherinto aCompletableand flatten all signals such that the returnedCompletableterminates when all mappedCompletables have terminated successfully or any one of them has terminated with a failure.CompletableflatMapCompletableDelayError(java.util.function.Function<? super T,? extends Completable> mapper)Map each element of thisPublisherinto aCompletableand flatten all signals such that the returnedCompletableterminates when all mappedCompletables have terminated successfully or any one of them has terminated with a failure.CompletableflatMapCompletableDelayError(java.util.function.Function<? super T,? extends Completable> mapper, int maxConcurrency)Map each element of thisPublisherinto aCompletableand flatten all signals such that the returnedCompletableterminates when all mappedCompletables have terminated successfully or any one of them has terminated with a failure.CompletableflatMapCompletableDelayError(java.util.function.Function<? super T,? extends Completable> mapper, int maxConcurrency, int maxDelayedErrorsHint)Map each element of thisPublisherinto aCompletableand flatten all signals such that the returnedCompletableterminates when all mappedCompletables have terminated successfully or any one of them has terminated with a failure.<R> Publisher<R>flatMapConcatIterable(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> mapper)<R> Publisher<R>flatMapMerge(java.util.function.Function<? super T,? extends Publisher<? extends R>> mapper)<R> Publisher<R>flatMapMerge(java.util.function.Function<? super T,? extends Publisher<? extends R>> mapper, int maxConcurrency)<R> Publisher<R>flatMapMergeDelayError(java.util.function.Function<? super T,? extends Publisher<? extends R>> mapper)<R> Publisher<R>flatMapMergeDelayError(java.util.function.Function<? super T,? extends Publisher<? extends R>> mapper, int maxConcurrency)<R> Publisher<R>flatMapMergeDelayError(java.util.function.Function<? super T,? extends Publisher<? extends R>> mapper, int maxConcurrency, int maxDelayedErrorsHint)<R> Publisher<R>flatMapMergeSingle(java.util.function.Function<? super T,? extends Single<? extends R>> mapper)<R> Publisher<R>flatMapMergeSingle(java.util.function.Function<? super T,? extends Single<? extends R>> mapper, int maxConcurrency)<R> Publisher<R>flatMapMergeSingleDelayError(java.util.function.Function<? super T,? extends Single<? extends R>> mapper)<R> Publisher<R>flatMapMergeSingleDelayError(java.util.function.Function<? super T,? extends Single<? extends R>> mapper, int maxConcurrency)<R> Publisher<R>flatMapMergeSingleDelayError(java.util.function.Function<? super T,? extends Single<? extends R>> mapper, int maxConcurrency, int maxDelayedErrorsHint)CancellableforEach(java.util.function.Consumer<? super T> forEach)static <T> Publisher<T>from(T value)Creates a newPublisherthat emitsvalueto itsPublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().static <T> Publisher<T>from(T... values)Creates a newPublisherthat emits allvaluesto itsPublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().static <T> Publisher<T>from(T v1, T v2)Creates a newPublisherthat emitsv1andv2to itsPublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().static <T> Publisher<T>from(T v1, T v2, T v3)Creates a newPublisherthat emitsv1,v2, andv3to itsPublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().static <T> Publisher<T>fromBlockingIterable(BlockingIterable<? extends T> iterable, java.util.function.LongSupplier timeoutSupplier, java.util.concurrent.TimeUnit unit)Create a newPublisherthat when subscribed will get aBlockingIteratorviaBlockingIterable.iterator()and emit all values to thePublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().static Publisher<byte[]>fromInputStream(java.io.InputStream stream)Create a newPublisherthat when subscribed will emit all data from theInputStreamto thePublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().static Publisher<byte[]>fromInputStream(java.io.InputStream stream, int readChunkSize)Create a newPublisherthat when subscribed will emit all data from theInputStreamto thePublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().static <T> Publisher<T>fromIterable(java.lang.Iterable<? extends T> iterable)Create a newPublisherthat when subscribed will get anIteratorviaIterable.iterator()and emit all values to thePublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().<Key> Publisher<GroupedPublisher<Key,T>>groupBy(java.util.function.Function<? super T,? extends Key> keySelector, int groupMaxQueueSize)Splits items from thisPublisherinto dynamically generatedGroupedPublishers.<Key> Publisher<GroupedPublisher<Key,T>>groupBy(java.util.function.Function<? super T,? extends Key> keySelector, int groupMaxQueueSize, int expectedGroupCountHint)Splits items from thisPublisherinto dynamically generatedGroupedPublishers.<Key> Publisher<GroupedPublisher<Key,T>>groupToMany(java.util.function.Function<? super T,? extends java.util.Iterator<? extends Key>> keySelector, int groupMaxQueueSize)The semantics are identical togroupBy(Function, int)except that thekeySelectorcan map each data to multiple keys.<Key> Publisher<GroupedPublisher<Key,T>>groupToMany(java.util.function.Function<? super T,? extends java.util.Iterator<? extends Key>> keySelector, int groupMaxQueueSize, int expectedGroupCountHint)The semantics are identical togroupBy(Function, int)except that thekeySelectorcan map each data to multiple keys.protected abstract voidhandleSubscribe(PublisherSource.Subscriber<? super T> subscriber)Handles a subscriber to thisPublisher.Publisher<T>idleTimeout(long duration, java.util.concurrent.TimeUnit unit)Deprecated.Publisher<T>idleTimeout(long duration, java.util.concurrent.TimeUnit unit, Executor timeoutExecutor)Deprecated.Publisher<T>idleTimeout(java.time.Duration duration)Deprecated.Publisher<T>idleTimeout(java.time.Duration duration, Executor timeoutExecutor)Deprecated.CompletableignoreElements()Ignores all elements emitted by thisPublisherand forwards the termination signal to the returnedCompletable.<R> Publisher<R>liftAsync(PublisherOperator<? super T,? extends R> operator)This method requires advanced knowledge of building operators.<R> Publisher<R>liftSync(PublisherOperator<? super T,? extends R> operator)This method requires advanced knowledge of building operators.<R> Single<R>liftSyncToSingle(PublisherToSingleOperator<? super T,? extends R> operator)This method requires advanced knowledge of building operators.<R> Publisher<R>map(java.util.function.Function<? super T,? extends R> mapper)Transforms elements emitted by thisPublisherinto a different type.Publisher<T>multicastToExactly(int expectedSubscribers)Create aPublisherthat multicasts all the signals to exactlyexpectedSubscribers.Publisher<T>multicastToExactly(int expectedSubscribers, int maxQueueSize)Create aPublisherthat allows exactlyexpectedSubscriberssubscribes.static <T> Publisher<T>never()Creates a newPublisherthat never emits any item to itsPublisherSource.Subscriberand never call any terminal methods on it.Publisher<T>onErrorComplete()Transform errors emitted on thisPublisherinto aPublisherSource.Subscriber.onComplete()signal (e.g.<E extends java.lang.Throwable>
Publisher<T>onErrorComplete(java.lang.Class<E> type)Transform errors emitted on thisPublisherwhich matchtypeinto aPublisherSource.Subscriber.onComplete()signal (e.g.Publisher<T>onErrorComplete(java.util.function.Predicate<? super java.lang.Throwable> predicate)Transform errors emitted on thisPublisherwhich matchpredicateinto aPublisherSource.Subscriber.onComplete()signal (e.g.<E extends java.lang.Throwable>
Publisher<T>onErrorMap(java.lang.Class<E> type, java.util.function.Function<? super E,? extends java.lang.Throwable> mapper)Transform errors emitted on thisPublisherwhich matchtypeinto a different error.Publisher<T>onErrorMap(java.util.function.Function<? super java.lang.Throwable,? extends java.lang.Throwable> mapper)Transform errors emitted on thisPublisherinto a different error.Publisher<T>onErrorMap(java.util.function.Predicate<? super java.lang.Throwable> predicate, java.util.function.Function<? super java.lang.Throwable,? extends java.lang.Throwable> mapper)Transform errors emitted on thisPublisherwhich matchpredicateinto a different error.<E extends java.lang.Throwable>
Publisher<T>onErrorResume(java.lang.Class<E> type, java.util.function.Function<? super E,? extends Publisher<? extends T>> nextFactory)Publisher<T>onErrorResume(java.util.function.Function<? super java.lang.Throwable,? extends Publisher<? extends T>> nextFactory)Publisher<T>onErrorResume(java.util.function.Predicate<? super java.lang.Throwable> predicate, java.util.function.Function<? super java.lang.Throwable,? extends Publisher<? extends T>> nextFactory)<E extends java.lang.Throwable>
Publisher<T>onErrorReturn(java.lang.Class<E> type, java.util.function.Function<? super E,? extends T> itemSupplier)Transform errors emitted on thisPublisherwhich matchtypeintoPublisherSource.Subscriber.onNext(Object)thenPublisherSource.Subscriber.onComplete()signals (e.g.Publisher<T>onErrorReturn(java.util.function.Function<? super java.lang.Throwable,? extends T> itemSupplier)Transform errors emitted on thisPublisherintoPublisherSource.Subscriber.onNext(Object)thenPublisherSource.Subscriber.onComplete()signals (e.g.Publisher<T>onErrorReturn(java.util.function.Predicate<? super java.lang.Throwable> predicate, java.util.function.Function<? super java.lang.Throwable,? extends T> itemSupplier)Transform errors emitted on thisPublisherwhich matchpredicateintoPublisherSource.Subscriber.onNext(Object)thenPublisherSource.Subscriber.onComplete()signals (e.g.Publisher<T>publishAndSubscribeOn(Executor executor)Creates a newPublisherthat will use the passedExecutorto invoke the following methods: AllPublisherSource.Subscribermethods. AllPublisherSource.Subscriptionmethods. ThehandleSubscribe(PublisherSource.Subscriber)method. This method does not override precedingExecutors, if any, specified forthisPublisher.Publisher<T>publishAndSubscribeOnOverride(Executor executor)Creates a newPublisherthat will use the passedExecutorto invoke the following methods: AllPublisherSource.Subscribermethods. AllPublisherSource.Subscriptionmethods. ThehandleSubscribe(PublisherSource.Subscriber)method. This method overrides precedingExecutors, if any, specified forthisPublisher.Publisher<T>publishOn(Executor executor)Creates a newPublisherthat will use the passedExecutorto invoke allPublisherSource.Subscribermethods.Publisher<T>publishOnOverride(Executor executor)Creates a newPublisherthat will use the passedExecutorto invoke allPublisherSource.Subscribermethods.static Publisher<java.lang.Integer>range(int begin, int end)Create a newPublisherthat when subscribed will emit allIntegers within the range of [begin,end).static Publisher<java.lang.Integer>range(int begin, int end, int stride)Create a newPublisherthat when subscribed will emit allIntegers within the range of [begin,end) with an increment ofstridebetween each signal.Publisher<T>recoverWith(java.util.function.Function<java.lang.Throwable,? extends Publisher<? extends T>> nextFactory)Deprecated.Publisher<T>repeat(java.util.function.IntPredicate shouldRepeat)Publisher<T>repeatWhen(java.util.function.IntFunction<? extends Completable> repeatWhen)Re-subscribes to thisPublisherwhen it completes and theCompletablereturned by the suppliedIntFunctioncompletes successfully.Publisher<T>retry(BiIntPredicate<java.lang.Throwable> shouldRetry)Publisher<T>retryWhen(BiIntFunction<java.lang.Throwable,? extends Completable> retryWhen)Re-subscribes to thisPublisherif an error is emitted and theCompletablereturned by the suppliedBiIntFunctioncompletes successfully.<R> Publisher<R>scanWith(java.util.function.Supplier<? extends ScanWithMapper<? super T,? extends R>> mapperSupplier)Apply a function to eachPublisherSource.Subscriber.onNext(Object)emitted by thisPublisheras well as optionally concat onePublisherSource.Subscriber.onNext(Object)signal before the terminal signal is emitted downstream.<R> Publisher<R>scanWith(java.util.function.Supplier<R> initial, java.util.function.BiFunction<R,? super T,R> accumulator)Apply aBiFunctionto eachPublisherSource.Subscriber.onNext(Object)emitted by thisPublisherand an accumulated state.<R> Publisher<R>scanWithLifetime(java.util.function.Supplier<? extends ScanWithLifetimeMapper<? super T,? extends R>> mapperSupplier)Apply a function to eachPublisherSource.Subscriber.onNext(Object)emitted by thisPublisheras well as optionally concat onePublisherSource.Subscriber.onNext(Object)signal before the terminal signal is emitted downstream.protected voidsubscribeInternal(PublisherSource.Subscriber<? super T> subscriber)A internal subscribe method similar toPublisherSource.subscribe(Subscriber)which can be used by different implementations to subscribe.Publisher<T>subscribeOn(Executor executor)Creates a newPublisherthat will use the passedExecutorto invoke the following methods: AllPublisherSource.Subscriptionmethods. ThehandleSubscribe(PublisherSource.Subscriber)method. This method does not override precedingExecutors, if any, specified forthisPublisher.Publisher<T>subscribeOnOverride(Executor executor)Creates a newPublisherthat will use the passedExecutorto invoke the following methods: AllPublisherSource.Subscriptionmethods. ThehandleSubscribe(PublisherSource.Subscriber)method. This method overrides precedingExecutors, if any, specified forthisPublisher.Publisher<T>subscribeShareContext()Signifies that when the returnedPublisheris subscribed to, theAsyncContextwill be shared instead of making acopy.Publisher<T>takeAtMost(long numElements)Publisher<T>takeUntil(Completable until)Takes elements untilCompletableis terminated successfully or with failure.Publisher<T>takeWhile(java.util.function.Predicate<? super T> predicate)Takes elements whilePredicateistrueand then cancelPublisherSource.Subscriptionof thisPublisheronce it returnsfalse.Publisher<T>timeout(long duration, java.util.concurrent.TimeUnit unit)Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between adjacentPublisherSource.Subscriber.onNext(Object)calls.Publisher<T>timeout(long duration, java.util.concurrent.TimeUnit unit, Executor timeoutExecutor)Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between adjacentPublisherSource.Subscriber.onNext(Object)calls.Publisher<T>timeout(java.time.Duration duration)Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between adjacentPublisherSource.Subscriber.onNext(Object)calls.Publisher<T>timeout(java.time.Duration duration, Executor timeoutExecutor)Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between adjacentPublisherSource.Subscriber.onNext(Object)calls.Publisher<T>timeoutTerminal(long duration, java.util.concurrent.TimeUnit unit)Publisher<T>timeoutTerminal(long duration, java.util.concurrent.TimeUnit unit, Executor timeoutExecutor)Publisher<T>timeoutTerminal(java.time.Duration duration)Publisher<T>timeoutTerminal(java.time.Duration duration, Executor timeoutExecutor)java.util.concurrent.CompletionStage<java.util.Collection<T>>toCompletionStage()<R> java.util.concurrent.CompletionStage<R>toCompletionStage(java.util.function.Supplier<? extends R> resultFactory, java.util.function.BiFunction<? super R,? super T,R> reducer)java.util.concurrent.Future<java.util.Collection<T>>toFuture()<R> java.util.concurrent.Future<R>toFuture(java.util.function.Supplier<? extends R> resultFactory, java.util.function.BiFunction<? super R,? super T,R> reducer)java.io.InputStreamtoInputStream(java.util.function.Function<? super T,byte[]> serializer)Subscribes tothisPublisherand converts all signals received by thePublisherSource.Subscriberto the returnedInputStreamfollowing the below rules:PublisherSource.Subscriptionreceived byPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is used to request more data when required.java.io.InputStreamtoInputStream(java.util.function.Function<? super T,byte[]> serializer, int queueCapacity)Subscribes tothisPublisherand converts all signals received by thePublisherSource.Subscriberto the returnedInputStreamfollowing the below rules:PublisherSource.Subscriptionreceived byPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is used to request more data when required.BlockingIterable<T>toIterable()BlockingIterable<T>toIterable(int queueCapacityHint)Publisher<T>whenCancel(java.lang.Runnable onCancel)Invokes theonCancelRunnableargument whenCancellable.cancel()is called for Subscriptions of the returnedPublisher.Publisher<T>whenFinally(TerminalSignalConsumer doFinally)Invokes the corresponding method onwhenFinallyTerminalSignalConsumerargument when any of the following terminal methods are called:PublisherSource.Subscriber.onComplete()- invokesTerminalSignalConsumer.onComplete()PublisherSource.Subscriber.onError(Throwable)- invokesTerminalSignalConsumer.onError(Throwable)Cancellable.cancel()- invokesTerminalSignalConsumer.cancel()forPublisherSource.Subscriptions/PublisherSource.Subscribers of the returnedPublisher.Publisher<T>whenFinally(java.lang.Runnable doFinally)Invokes thewhenFinallyRunnableargument exactly once, when any of the following terminal methods are called:PublisherSource.Subscriber.onComplete()PublisherSource.Subscriber.onError(Throwable)Cancellable.cancel()forPublisherSource.Subscriptions/PublisherSource.Subscribers of the returnedPublisher.Publisher<T>whenOnComplete(java.lang.Runnable onComplete)Invokes theonCompleteRunnableargument whenPublisherSource.Subscriber.onComplete()is called forPublisherSource.Subscribers of the returnedPublisher.Publisher<T>whenOnError(java.util.function.Consumer<java.lang.Throwable> onError)Invokes theonErrorConsumerargument whenPublisherSource.Subscriber.onError(Throwable)is called forPublisherSource.Subscribers of the returnedPublisher.Publisher<T>whenOnNext(java.util.function.Consumer<? super T> onNext)Invokes theonNextConsumerargument whenPublisherSource.Subscriber.onNext(Object)is called forPublisherSource.Subscribers of the returnedPublisher.Publisher<T>whenOnSubscribe(java.util.function.Consumer<? super PublisherSource.Subscription> onSubscribe)Invokes theonSubscribeConsumerargument whenPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is called forPublisherSource.Subscribers of the returnedPublisher.Publisher<T>whenRequest(java.util.function.LongConsumer onRequest)Invokes theonRequestLongConsumerargument whenPublisherSource.Subscription.request(long)is called forPublisherSource.Subscriptions of the returnedPublisher.Publisher<T>whenSubscriber(java.util.function.Supplier<? extends PublisherSource.Subscriber<? super T>> subscriberSupplier)Creates a newPublisherSource.Subscriber(via thesubscriberSupplierargument) for each new subscribe and invokes methods on thatPublisherSource.Subscriberwhen the corresponding methods are called forPublisherSource.Subscribers of the returnedPublisher.Publisher<T>whenSubscription(java.util.function.Supplier<? extends PublisherSource.Subscription> subscriptionSupplier)Creates a newPublisherSource.Subscription(via thesubscriptionSupplierargument) for each new subscribe and invokes all thePublisherSource.Subscriptionmethods when the corresponding methods are called forPublisherSource.Subscriptions of the returnedPublisher.
-
-
-
Method Detail
-
map
public final <R> Publisher<R> map(java.util.function.Function<? super T,? extends R> mapper)
Transforms elements emitted by thisPublisherinto a different type.This method provides a data transformation in sequential programming similar to:
List<R> results = ...; for (T t : resultOfThisPublisher()) { results.add(mapper.apply(t)); } return results;- Type Parameters:
R- Type of the items emitted by the returnedPublisher.- Parameters:
mapper- Function to transform each item emitted by thisPublisher.- Returns:
- A
Publisherthat transforms elements emitted by thisPublisherinto a different type. - See Also:
- ReactiveX map operator.
-
filter
public final Publisher<T> filter(java.util.function.Predicate<? super T> predicate)
Filters items emitted by thisPublisher.This method provides a data transformation in sequential programming similar to:
List<T> results = ...; for (T t : resultOfThisPublisher()) { if (predicate.test(t)) { results.add(t); } } return results;- Parameters:
predicate- for the filter.- Returns:
- A
Publisherthat only emits the items that pass thepredicate. - See Also:
- ReactiveX filter operator.
-
scanWith
public final <R> Publisher<R> scanWith(java.util.function.Supplier<R> initial, java.util.function.BiFunction<R,? super T,R> accumulator)
Apply aBiFunctionto eachPublisherSource.Subscriber.onNext(Object)emitted by thisPublisherand an accumulated state.This method provides a data transformation in sequential programming similar to:
List<R> results = ...; R state = initial.get(); for (T t : resultOfThisPublisher()) { state = accumulator.apply(state, t); results.add(state); } return results;- Type Parameters:
R- Type of the items emitted by the returnedPublisher.- Parameters:
initial- Invoked on eachPublisherSource.subscribe(Subscriber)and provides the initial state for eachPublisherSource.Subscriber.accumulator- Used to accumulate the current state in combination with eachPublisherSource.Subscriber.onNext(Object)from thisPublisher.- Returns:
- A
Publisherthat transforms elements emitted by thisPublisherinto a different type. - See Also:
- ReactiveX scan operator.
-
scanWith
public final <R> Publisher<R> scanWith(java.util.function.Supplier<? extends ScanWithMapper<? super T,? extends R>> mapperSupplier)
Apply a function to eachPublisherSource.Subscriber.onNext(Object)emitted by thisPublisheras well as optionally concat onePublisherSource.Subscriber.onNext(Object)signal before the terminal signal is emitted downstream.This method provides a data transformation in sequential programming similar to:
List<R> results = ...; ScanWithMapper<T, R> mapper = mapperSupplier.get(); try { for (T t : resultOfThisPublisher()) { results.add(mapper.mapOnNext(t)); } } catch (Throwable cause) { if (mapTerminal.test(state)) { results.add(mapper.mapOnError(cause)); return; } throw cause; } if (mapTerminal.test(state)) { results.add(mapper.mapOnComplete()); } return results;- Type Parameters:
R- Type of the items emitted by the returnedPublisher.- Parameters:
mapperSupplier- Invoked on eachPublisherSource.subscribe(Subscriber)and maintains any necessary state for the mapping/accumulation for eachPublisherSource.Subscriber.- Returns:
- A
Publisherthat transforms elements emitted by thisPublisherinto a different type. - See Also:
- ReactiveX scan operator.
-
scanWithLifetime
public final <R> Publisher<R> scanWithLifetime(java.util.function.Supplier<? extends ScanWithLifetimeMapper<? super T,? extends R>> mapperSupplier)
Apply a function to eachPublisherSource.Subscriber.onNext(Object)emitted by thisPublisheras well as optionally concat onePublisherSource.Subscriber.onNext(Object)signal before the terminal signal is emitted downstream. Additionally theScanWithLifetimeMapper.afterFinally()method will be invoked on terminal or cancel signals which enables cleanup of state (if required). This provides a similar lifetime management asTerminalSignalConsumer.This method provides a data transformation in sequential programming similar to:
List<R> results = ...; ScanWithLifetimeMapper<T, R> mapper = mapperSupplier.get(); try { try { for (T t : resultOfThisPublisher()) { results.add(mapper.mapOnNext(t)); } } catch (Throwable cause) { if (mapTerminal.test(state)) { results.add(mapper.mapOnError(cause)); return; } throw cause; } if (mapTerminal.test(state)) { results.add(mapper.mapOnComplete()); } } finally { mapper.afterFinally(); } return results;- Type Parameters:
R- Type of the items emitted by the returnedPublisher.- Parameters:
mapperSupplier- Invoked on eachPublisherSource.subscribe(Subscriber)and maintains any necessary state for the mapping/accumulation for eachPublisherSource.Subscriber.- Returns:
- A
Publisherthat transforms elements emitted by thisPublisherinto a different type. - See Also:
- ReactiveX scan operator.
-
onErrorComplete
public final Publisher<T> onErrorComplete()
Transform errors emitted on thisPublisherinto aPublisherSource.Subscriber.onComplete()signal (e.g. swallows the error).This method provides a data transformation in sequential programming similar to:
List<T> results = resultOfThisPublisher(); try { terminalOfThisPublisher(); } catch (Throwable cause) { // ignored } return results;- Returns:
- A
Publisherwhich transform errors emitted on thisPublisherinto aPublisherSource.Subscriber.onComplete()signal (e.g. swallows the error). - See Also:
- ReactiveX catch operator.
-
onErrorComplete
public final <E extends java.lang.Throwable> Publisher<T> onErrorComplete(java.lang.Class<E> type)
Transform errors emitted on thisPublisherwhich matchtypeinto aPublisherSource.Subscriber.onComplete()signal (e.g. swallows the error).This method provides a data transformation in sequential programming similar to:
List<T> results = resultOfThisPublisher(); try { terminalOfThisPublisher(); } catch (Throwable cause) { if (!type.isInstance(cause)) { throw cause; } } return results;- Type Parameters:
E- TheThrowabletype.- Parameters:
type- TheThrowabletype to filter, operator will not apply for errors which don't match this type.- Returns:
- A
Publisherwhich transform errors emitted on thisPublisherwhich matchtypeinto aPublisherSource.Subscriber.onComplete()signal (e.g. swallows the error). - See Also:
- ReactiveX catch operator.
-
onErrorComplete
public final Publisher<T> onErrorComplete(java.util.function.Predicate<? super java.lang.Throwable> predicate)
Transform errors emitted on thisPublisherwhich matchpredicateinto aPublisherSource.Subscriber.onComplete()signal (e.g. swallows the error).This method provides a data transformation in sequential programming similar to:
List<T> results = resultOfThisPublisher(); try { terminalOfThisPublisher(); } catch (Throwable cause) { if (!predicate.test(cause)) { throw cause; } } return results;- Parameters:
predicate- returnstrueif theThrowableshould be transformed to andPublisherSource.Subscriber.onComplete()signal. Returnsfalseto propagate the error.- Returns:
- A
Publisherwhich transform errors emitted on thisPublisherwhich matchpredicateinto aPublisherSource.Subscriber.onComplete()signal (e.g. swallows the error). - See Also:
- ReactiveX catch operator.
-
onErrorReturn
public final Publisher<T> onErrorReturn(java.util.function.Function<? super java.lang.Throwable,? extends T> itemSupplier)
Transform errors emitted on thisPublisherintoPublisherSource.Subscriber.onNext(Object)thenPublisherSource.Subscriber.onComplete()signals (e.g. swallows the error).This method provides a data transformation in sequential programming similar to:
List<T> results = resultOfThisPublisher(); try { terminalOfThisPublisher(); } catch (Throwable cause) { results.add(itemSupplier.apply(cause)); } return results;- Parameters:
itemSupplier- returns the element to emit toPublisherSource.Subscriber.onNext(Object).- Returns:
- A
Publisherwhich transform errors emitted on thisPublisherintoPublisherSource.Subscriber.onNext(Object)thenPublisherSource.Subscriber.onComplete()signals (e.g. swallows the error). - See Also:
- ReactiveX catch operator.
-
onErrorReturn
public final <E extends java.lang.Throwable> Publisher<T> onErrorReturn(java.lang.Class<E> type, java.util.function.Function<? super E,? extends T> itemSupplier)
Transform errors emitted on thisPublisherwhich matchtypeintoPublisherSource.Subscriber.onNext(Object)thenPublisherSource.Subscriber.onComplete()signals (e.g. swallows the error).This method provides a data transformation in sequential programming similar to:
List<T> results = resultOfThisPublisher(); try { terminalOfThisPublisher(); } catch (Throwable cause) { if (!type.isInstance(cause)) { throw cause; } results.add(itemSupplier.apply(cause)); } return results;- Type Parameters:
E- The type ofThrowableto transform.- Parameters:
type- TheThrowabletype to filter, operator will not apply for errors which don't match this type.itemSupplier- returns the element to emit toPublisherSource.Subscriber.onNext(Object).- Returns:
- A
Publisherwhich transform errors emitted on thisPublisherintoPublisherSource.Subscriber.onNext(Object)thenPublisherSource.Subscriber.onComplete()signals (e.g. swallows the error). - See Also:
- ReactiveX catch operator.
-
onErrorReturn
public final Publisher<T> onErrorReturn(java.util.function.Predicate<? super java.lang.Throwable> predicate, java.util.function.Function<? super java.lang.Throwable,? extends T> itemSupplier)
Transform errors emitted on thisPublisherwhich matchpredicateintoPublisherSource.Subscriber.onNext(Object)thenPublisherSource.Subscriber.onComplete()signals (e.g. swallows the error).This method provides a data transformation in sequential programming similar to:
List<T> results = resultOfThisPublisher(); try { terminalOfThisPublisher(); } catch (Throwable cause) { if (!predicate.test(cause)) { throw cause; } results.add(itemSupplier.apply(cause)); } return result;- Parameters:
predicate- returnstrueif theThrowableshould be transformed toPublisherSource.Subscriber.onNext(Object)thenPublisherSource.Subscriber.onComplete()signals. Returnsfalseto propagate the error.itemSupplier- returns the element to emit toPublisherSource.Subscriber.onNext(Object).- Returns:
- A
Publisherwhich transform errors emitted on thisPublisherintoPublisherSource.Subscriber.onNext(Object)thenPublisherSource.Subscriber.onComplete()signals (e.g. swallows the error). - See Also:
- ReactiveX catch operator.
-
onErrorMap
public final Publisher<T> onErrorMap(java.util.function.Function<? super java.lang.Throwable,? extends java.lang.Throwable> mapper)
Transform errors emitted on thisPublisherinto a different error.This method provides a data transformation in sequential programming similar to:
List<T> results = resultOfThisPublisher(); try { terminalOfThisPublisher(); } catch (Throwable cause) { throw mapper.apply(cause); } return results;- Parameters:
mapper- returns the error used to terminate the returnedPublisher.- Returns:
- A
Publisherwhich transform errors emitted on thisPublisherinto a different error. - See Also:
- ReactiveX catch operator.
-
onErrorMap
public final <E extends java.lang.Throwable> Publisher<T> onErrorMap(java.lang.Class<E> type, java.util.function.Function<? super E,? extends java.lang.Throwable> mapper)
Transform errors emitted on thisPublisherwhich matchtypeinto a different error.This method provides a data transformation in sequential programming similar to:
List<T> results = resultOfThisPublisher(); try { terminalOfThisPublisher(); } catch (Throwable cause) { if (type.isInstance(cause)) { throw mapper.apply(cause); } else { throw cause; } } return results;- Type Parameters:
E- The type ofThrowableto transform.- Parameters:
type- TheThrowabletype to filter, operator will not apply for errors which don't match this type.mapper- returns the error used to terminate the returnedPublisher.- Returns:
- A
Publisherwhich transform errors emitted on thisPublisherinto a different error. - See Also:
- ReactiveX catch operator.
-
onErrorMap
public final Publisher<T> onErrorMap(java.util.function.Predicate<? super java.lang.Throwable> predicate, java.util.function.Function<? super java.lang.Throwable,? extends java.lang.Throwable> mapper)
Transform errors emitted on thisPublisherwhich matchpredicateinto a different error.This method provides a data transformation in sequential programming similar to:
List<T> results = resultOfThisPublisher(); try { terminalOfThisPublisher(); } catch (Throwable cause) { if (predicate.test(cause)) { throw mapper.apply(cause); } else { throw cause; } } return results;- Parameters:
predicate- returnstrueif theThrowableshould be transformed viamapper. Returnsfalseto propagate the original error.mapper- returns the error used to terminate the returnedPublisher.- Returns:
- A
Publisherwhich transform errors emitted on thisPublisherinto a different error. - See Also:
- ReactiveX catch operator.
-
onErrorResume
public final Publisher<T> onErrorResume(java.util.function.Function<? super java.lang.Throwable,? extends Publisher<? extends T>> nextFactory)
Recover from any error emitted by thisPublisherby using anotherPublisherprovided by the passednextFactory.This method provides similar capabilities to a try/catch block in sequential programming:
List<T> results; try { results = resultOfThisPublisher(); } catch (Throwable cause) { // Note that nextFactory returning a error Publisher is like re-throwing (nextFactory shouldn't throw). results = nextFactory.apply(cause); } return results;
-
onErrorResume
public final <E extends java.lang.Throwable> Publisher<T> onErrorResume(java.lang.Class<E> type, java.util.function.Function<? super E,? extends Publisher<? extends T>> nextFactory)
Recover from errors emitted by thisPublisherwhich matchtypeby using anotherPublisherprovided by the passednextFactory.This method provides similar capabilities to a try/catch block in sequential programming:
List<T> results; try { results = resultOfThisPublisher(); } catch (Throwable cause) { if (type.isInstance(cause)) { // Note that nextFactory returning a error Publisher is like re-throwing (nextFactory shouldn't throw). results = nextFactory.apply(cause); } else { throw cause; } } return results;- Type Parameters:
E- The type ofThrowableto transform.- Parameters:
type- TheThrowabletype to filter, operator will not apply for errors which don't match this type.nextFactory- Returns the nextPublisher, when thisPublisheremits an error.- Returns:
- A
Publisherthat recovers from an error from thisPublisherby using anotherPublisherprovided by the passednextFactory. - See Also:
- ReactiveX catch operator.
-
onErrorResume
public final Publisher<T> onErrorResume(java.util.function.Predicate<? super java.lang.Throwable> predicate, java.util.function.Function<? super java.lang.Throwable,? extends Publisher<? extends T>> nextFactory)
Recover from errors emitted by thisPublisherwhich matchpredicateby using anotherPublisherprovided by the passednextFactory.This method provides similar capabilities to a try/catch block in sequential programming:
List<T> results; try { results = resultOfThisPublisher(); } catch (Throwable cause) { if (predicate.test(cause)) { // Note that nextFactory returning a error Publisher is like re-throwing (nextFactory shouldn't throw). results = nextFactory.apply(cause); } else { throw cause; } } return results;- Parameters:
predicate- returnstrueif theThrowableshould be transformed vianextFactory. Returnsfalseto propagate the original error.nextFactory- Returns the nextPublisher, when thisPublisheremits an error.- Returns:
- A
Publisherthat recovers from an error from thisPublisherby using anotherPublisherprovided by the passednextFactory. - See Also:
- ReactiveX catch operator.
-
recoverWith
@Deprecated public final Publisher<T> recoverWith(java.util.function.Function<java.lang.Throwable,? extends Publisher<? extends T>> nextFactory)
Deprecated.Recover from any error emitted by thisPublisherby using anotherPublisherprovided by the passednextFactory.This method provides similar capabilities to a try/catch block in sequential programming:
List<T> results; try { results = resultOfThisPublisher(); } catch (Throwable cause) { // Note that nextFactory returning a error Publisher is like re-throwing (nextFactory shouldn't throw). results = nextFactory.apply(cause); } return results;- Parameters:
nextFactory- Returns the nextPublisher, when thisPublisheremits an error.- Returns:
- A
Publisherthat recovers from an error from thisPublisherby using anotherPublisherprovided by the passednextFactory. - See Also:
- ReactiveX catch operator.
-
flatMapMerge
public final <R> Publisher<R> flatMapMerge(java.util.function.Function<? super T,? extends Publisher<? extends R>> mapper)
Map each element of thisPublisherinto aPublisher<Publisher> and flatten all signals emitted from each mappedPublisher<Publisher> into the returnedPublisher<Publisher>.To control the amount of concurrent processing done by this operator see
flatMapMerge(Function, int).This method is similar to
map(Function)but the result is an asynchronous stream, and provides a data transformation in sequential programming similar to:ExecutorService e = ...; List<Future<List<R>>> futures = ...; // assume this is thread safe for (T t : resultOfThisPublisher()) { // Note that flatMap process results in parallel. futures.add(e.submit(() -> { return mapper.apply(t); // Asynchronous result is flatten into a value by this operator. })); } List<R> results = new ArrayList<>(futures.size()); // This is an approximation, this operator does not provide any ordering guarantees for the results. for (Future<List<R>> future : futures) { List<R> rList = future.get(); // Throws if the processing for this item failed. results.addAll(rList); } return results;
-
flatMapMerge
public final <R> Publisher<R> flatMapMerge(java.util.function.Function<? super T,? extends Publisher<? extends R>> mapper, int maxConcurrency)
Map each element of thisPublisherinto aPublisher<Publisher> and flatten all signals emitted from each mappedPublisher<Publisher> into the returnedPublisher<Publisher>.This method is similar to
map(Function)but the result is an asynchronous stream, and provides a data transformation in sequential programming similar to:ExecutorService e = ...; List<Future<List<R>>> futures = ...; // assume this is thread safe for (T t : resultOfThisPublisher()) { // Note that flatMap process results in parallel. futures.add(e.submit(() -> { return mapper.apply(t); // Asynchronous result is flatten into a value by this operator. })); } List<R> results = new ArrayList<>(futures.size()); // This is an approximation, this operator does not provide any ordering guarantees for the results. for (Future<List<R>> future : futures) { List<R> rList = future.get(); // Throws if the processing for this item failed. results.addAll(rList); } return results;- Type Parameters:
R- The type of mappedPublisher.- Parameters:
mapper- Convert each item emitted by thisPublisherinto anotherPublisher.maxConcurrency- Maximum amount of outstanding upstreamdemand.- Returns:
- A new
Publisherwhich flattens the emissions from all mappedPublishers. - See Also:
- ReactiveX flatMap operator.
-
flatMapMergeDelayError
public final <R> Publisher<R> flatMapMergeDelayError(java.util.function.Function<? super T,? extends Publisher<? extends R>> mapper)
Map each element of thisPublisherinto aPublisher<Publisher> and flatten all signals emitted from each mappedPublisher<Publisher> into the returnedPublisher<Publisher>.This is the same as
flatMapMerge(Function)just that if any mappedPublisherreturned bymapper, terminates with an error, the returnedPublisherwill not immediately terminate. Instead, it will wait for thisPublisherand all mappedPublishers to terminate and then terminate the returnedPublisherwith all errors emitted by the mappedPublishers.To control the amount of concurrent processing done by this operator see
flatMapMergeDelayError(Function, int).This method is similar to
map(Function)but the result is an asynchronous stream, and provides a data transformation in sequential programming similar to:Executor e = ...; List<T> tResults = resultOfThisPublisher(); List<R> rResults = ...; // assume this is thread safe List<Throwable> errors = ...; // assume this is thread safe CountDownLatch latch = new CountDownLatch(tResults.size()); for (T t : resultOfThisPublisher()) { // Note that flatMap process results in parallel. e.execute(() -> { try { List<R> rList = mapper.apply(t); // Asynchronous result is flatten into a value by this operator. rResults.addAll(rList); } catch (Throwable cause) { errors.add(cause); // Asynchronous error is flatten into an error by this operator. } finally { latch.countdown(); } }); } latch.await(); if (errors.isEmpty()) { return rResults; } createAndThrowACompositeException(errors);
-
flatMapMergeDelayError
public final <R> Publisher<R> flatMapMergeDelayError(java.util.function.Function<? super T,? extends Publisher<? extends R>> mapper, int maxConcurrency)
Map each element of thisPublisherinto aPublisher<Publisher> and flatten all signals emitted from each mappedPublisher<Publisher> into the returnedPublisher<Publisher>.This is the same as
flatMapMerge(Function)just that if any mappedPublisherreturned bymapper, terminates with an error, the returnedPublisherwill not immediately terminate. Instead, it will wait for thisPublisherand all mappedPublishers to terminate and then terminate the returnedPublisherwith all errors emitted by the mappedPublishers.This method is similar to
map(Function)but the result is an asynchronous stream, and provides a data transformation in sequential programming similar to:Executor e = ...; List<T> tResults = resultOfThisPublisher(); List<R> rResults = ...; // assume this is thread safe List<Throwable> errors = ...; // assume this is thread safe CountDownLatch latch = new CountDownLatch(tResults.size()); for (T t : resultOfThisPublisher()) { // Note that flatMap process results in parallel. e.execute(() -> { try { List<R> rList = mapper.apply(t); // Asynchronous result is flatten into a value by this operator. rResults.addAll(rList); } catch (Throwable cause) { errors.add(cause); // Asynchronous error is flatten into an error by this operator. } finally { latch.countdown(); } }); } latch.await(); if (errors.isEmpty()) { return rResults; } createAndThrowACompositeException(errors);- Type Parameters:
R- The type of mappedPublisher.- Parameters:
mapper- Convert each item emitted by thisPublisherinto anotherPublisher.maxConcurrency- Maximum amount of outstanding upstreamdemand.- Returns:
- A new
Publisherwhich flattens the emissions from all mappedPublishers. - See Also:
- ReactiveX flatMap operator.
-
flatMapMergeDelayError
public final <R> Publisher<R> flatMapMergeDelayError(java.util.function.Function<? super T,? extends Publisher<? extends R>> mapper, int maxConcurrency, int maxDelayedErrorsHint)
Map each element of thisPublisherinto aPublisher<Publisher> and flatten all signals emitted from each mappedPublisher<Publisher> into the returnedPublisher<Publisher>.This is the same as
flatMapMerge(Function)just that if any mappedPublisherreturned bymapper, terminates with an error, the returnedPublisherwill not immediately terminate. Instead, it will wait for thisPublisherand all mappedPublishers to terminate and then terminate the returnedPublisherwith all errors emitted by the mappedPublishers.This method is similar to
map(Function)but the result is an asynchronous stream, and provides a data transformation in sequential programming similar to:Executor e = ...; List<T> tResults = resultOfThisPublisher(); List<R> rResults = ...; // assume this is thread safe List<Throwable> errors = ...; // assume this is thread safe CountDownLatch latch = new CountDownLatch(tResults.size()); for (T t : resultOfThisPublisher()) { // Note that flatMap process results in parallel. e.execute(() -> { try { List<R> rList = mapper.apply(t); // Asynchronous result is flatten into a value by this operator. rResults.addAll(rList); } catch (Throwable cause) { errors.add(cause); // Asynchronous error is flatten into an error by this operator. } finally { latch.countdown(); } }); } latch.await(); if (errors.isEmpty()) { return rResults; } createAndThrowACompositeException(errors);- Type Parameters:
R- The type of mappedPublisher.- Parameters:
mapper- Convert each item emitted by thisPublisherinto anotherPublisher.maxConcurrency- Maximum amount of outstanding upstreamdemand.maxDelayedErrorsHint- The maximum amount of errors that will be queued. After this point exceptions maybe discarded to reduce memory consumption.- Returns:
- A new
Publisherwhich flattens the emissions from all mappedPublishers. - See Also:
- ReactiveX flatMap operator.
-
flatMapMergeSingle
public final <R> Publisher<R> flatMapMergeSingle(java.util.function.Function<? super T,? extends Single<? extends R>> mapper)
Map each element of thisPublisherinto aSingle<Publisher> and flatten all signals emitted from each mappedSingle<Publisher> into the returnedPublisher<Publisher>.To control the amount of concurrent processing done by this operator see
flatMapMergeSingle(Function, int).This method is similar to
map(Function)but the result is asynchronous, and provides a data transformation in sequential programming similar to:ExecutorService e = ...; List<Future<R>> futures = ...; // assume this is thread safe for (T t : resultOfThisPublisher()) { // Note that flatMap process results in parallel. futures.add(e.submit(() -> { return mapper.apply(t); // Asynchronous result is flatten into a value by this operator. })); } List<R> results = new ArrayList<>(futures.size()); // This is an approximation, this operator does not provide any ordering guarantees for the results. for (Future<R> future : futures) { R r = future.get(); // Throws if the processing for this item failed. results.add(r); } return results;- Type Parameters:
R- Type of items emitted by the returnedPublisher.- Parameters:
mapper-Functionto convert each item emitted by thisPublisherinto aSingle.- Returns:
- A new
Publisherthat emits all items emitted by each single produced bymapper. - See Also:
- ReactiveX flatMap operator.,
flatMapMergeSingle(Function, int)
-
flatMapMergeSingle
public final <R> Publisher<R> flatMapMergeSingle(java.util.function.Function<? super T,? extends Single<? extends R>> mapper, int maxConcurrency)
Map each element of thisPublisherinto aSingle<Publisher> and flatten all signals emitted from each mappedSingle<Publisher> into the returnedPublisher<Publisher>.This method is similar to
map(Function)but the result is asynchronous, and provides a data transformation in sequential programming similar to:ExecutorService e = ...; List<Future<R>> futures = ...; // assume this is thread safe for (T t : resultOfThisPublisher()) { // Note that flatMap process results in parallel. futures.add(e.submit(() -> { return mapper.apply(t); // Asynchronous result is flatten into a value by this operator. })); } List<R> results = new ArrayList<>(futures.size()); // This is an approximation, this operator does not provide any ordering guarantees for the results. for (Future<R> future : futures) { R r = future.get(); // Throws if the processing for this item failed. results.add(r); } return results;- Type Parameters:
R- Type of items emitted by the returnedPublisher.- Parameters:
mapper-Functionto convert each item emitted by thisPublisherinto aSingle.maxConcurrency- Maximum activeSingles at any time. Even if the number of items requested by aPublisherSource.Subscriberis more than this number, this will never request more than this number at any point.- Returns:
- A new
Publisherthat emits all items emitted by each single produced bymapper. - See Also:
- ReactiveX flatMap operator.
-
flatMapMergeSingleDelayError
public final <R> Publisher<R> flatMapMergeSingleDelayError(java.util.function.Function<? super T,? extends Single<? extends R>> mapper)
Map each element of thisPublisherinto aSingle<Publisher> and flatten all signals emitted from each mappedSingle<Publisher> into the returnedPublisher<Publisher>.The behavior is the same as
flatMapMergeSingle(Function, int)with the exception that if anySinglereturned bymapper, terminates with an error, the returnedPublisherwill not immediately terminate. Instead, it will wait for thisPublisherand allSingles to terminate and then terminate the returnedPublisherwith all errors emitted by theSingles produced by themapper.To control the amount of concurrent processing done by this operator see
flatMapMergeSingleDelayError(Function, int).This method is similar to
map(Function)but the result is asynchronous, and provides a data transformation in sequential programming similar to:Executor e = ...; List<T> tResults = resultOfThisPublisher(); List<R> rResults = ...; // assume this is thread safe List<Throwable> errors = ...; // assume this is thread safe CountDownLatch latch = new CountDownLatch(tResults.size()); for (T t : tResults) { // Note that flatMap process results in parallel. e.execute(() -> { try { R r = mapper.apply(t); // Asynchronous result is flatten into a value by this operator. rResults.add(r); } catch (Throwable cause) { errors.add(cause); // Asynchronous error is flatten into an error by this operator. } finally { latch.countdown(); } }); } latch.await(); if (errors.isEmpty()) { return rResults; } createAndThrowACompositeException(errors);- Type Parameters:
R- Type of items emitted by the returnedPublisher.- Parameters:
mapper-Functionto convert each item emitted by thisPublisherinto aSingle.- Returns:
- A new
Publisherthat emits all items emitted by each single produced bymapper. - See Also:
- ReactiveX merge operator.,
flatMapMergeSingleDelayError(Function, int)
-
flatMapMergeSingleDelayError
public final <R> Publisher<R> flatMapMergeSingleDelayError(java.util.function.Function<? super T,? extends Single<? extends R>> mapper, int maxConcurrency)
Map each element of thisPublisherinto aSingle<Publisher> and flatten all signals emitted from each mappedSingle<Publisher> into the returnedPublisher<Publisher>.The behavior is the same as
flatMapMergeSingle(Function, int)with the exception that if anySinglereturned bymapper, terminates with an error, the returnedPublisherwill not immediately terminate. Instead, it will wait for thisPublisherand allSingles to terminate and then terminate the returnedPublisherwith all errors emitted by theSingles produced by themapper.This method is similar to
map(Function)but the result is asynchronous, and provides a data transformation in sequential programming similar to:Executor e = ...; List<T> tResults = resultOfThisPublisher(); List<R> rResults = ...; // assume this is thread safe List<Throwable> errors = ...; // assume this is thread safe CountDownLatch latch = new CountDownLatch(tResults.size()); for (T t : tResults) { // Note that flatMap process results in parallel. e.execute(() -> { try { R r = mapper.apply(t); // Asynchronous result is flatten into a value by this operator. rResults.add(r); } catch (Throwable cause) { errors.add(cause); // Asynchronous error is flatten into an error by this operator. } finally { latch.countdown(); } }); } latch.await(); if (errors.isEmpty()) { return rResults; } createAndThrowACompositeException(errors);- Type Parameters:
R- Type of items emitted by the returnedPublisher.- Parameters:
mapper-Functionto convert each item emitted by thisPublisherinto aSingle.maxConcurrency- Maximum activeSingles at any time. Even if the number of items requested by aPublisherSource.Subscriberis more than this number, this will never request more than this number at any point.- Returns:
- A new
Publisherthat emits all items emitted by each single produced bymapper. - See Also:
- ReactiveX merge operator.
-
flatMapMergeSingleDelayError
public final <R> Publisher<R> flatMapMergeSingleDelayError(java.util.function.Function<? super T,? extends Single<? extends R>> mapper, int maxConcurrency, int maxDelayedErrorsHint)
Map each element of thisPublisherinto aSingle<Publisher> and flatten all signals emitted from each mappedSingle<Publisher> into the returnedPublisher<Publisher>.The behavior is the same as
flatMapMergeSingle(Function, int)with the exception that if anySinglereturned bymapper, terminates with an error, the returnedPublisherwill not immediately terminate. Instead, it will wait for thisPublisherand allSingles to terminate and then terminate the returnedPublisherwith all errors emitted by theSingles produced by themapper.This method is similar to
map(Function)but the result is asynchronous, and provides a data transformation in sequential programming similar to:Executor e = ...; List<T> tResults = resultOfThisPublisher(); List<R> rResults = ...; // assume this is thread safe List<Throwable> errors = ...; // assume this is thread safe CountDownLatch latch = new CountDownLatch(tResults.size()); for (T t : tResults) { // Note that flatMap process results in parallel. e.execute(() -> { try { R r = mapper.apply(t); // Asynchronous result is flatten into a value by this operator. rResults.add(r); } catch (Throwable cause) { errors.add(cause); // Asynchronous error is flatten into an error by this operator. } finally { latch.countdown(); } }); } latch.await(); if (errors.isEmpty()) { return rResults; } createAndThrowACompositeException(errors);- Type Parameters:
R- Type of items emitted by the returnedPublisher.- Parameters:
mapper-Functionto convert each item emitted by thisPublisherinto aSingle.maxConcurrency- Maximum activeSingles at any time. Even if the number of items requested by aPublisherSource.Subscriberis more than this number, this will never request more than this number at any point.maxDelayedErrorsHint- The maximum amount of errors that will be queued. After this point exceptions maybe discarded to reduce memory consumption.- Returns:
- A new
Publisherthat emits all items emitted by each single produced bymapper. - See Also:
- ReactiveX merge operator.
-
flatMapCompletable
public final Completable flatMapCompletable(java.util.function.Function<? super T,? extends Completable> mapper)
Map each element of thisPublisherinto aCompletableand flatten all signals such that the returnedCompletableterminates when all mappedCompletables have terminated successfully or any one of them has terminated with a failure.If the returned
Completableshould wait for the termination of all mappedCompletables when any one of them terminates with a failure,flatMapCompletableDelayError(Function)should be used.To control the amount of concurrent processing done by this operator see
flatMapCompletable(Function, int).This method is similar to
map(Function)but the result is asynchronous, and provides a data transformation in sequential programming similar to:ExecutorService e = ...; List<Future<Void>> futures = ...; // assume this is thread safe for (T t : resultOfThisPublisher()) { // Note that flatMap process results in parallel. futures.add(e.submit(() -> { return mapper.apply(t); // Asynchronous result is flatten into a value by this operator. })); } // This is an approximation, this operator does not provide any ordering guarantees for the results. for (Future<R> future : futures) { future.get(); // Throws if the processing for this item failed. }- Parameters:
mapper-Functionto convert each item emitted by thisPublisherinto aCompletable.- Returns:
- A new
Completablethat terminates successfully if all the intermediateCompletables have terminated successfully or any one of them has terminated with a failure. - See Also:
- ReactiveX flatMap operator.,
flatMapCompletable(Function, int),flatMapCompletableDelayError(Function)
-
flatMapCompletable
public final Completable flatMapCompletable(java.util.function.Function<? super T,? extends Completable> mapper, int maxConcurrency)
Map each element of thisPublisherinto aCompletableand flatten all signals such that the returnedCompletableterminates when all mappedCompletables have terminated successfully or any one of them has terminated with a failure.If the returned
Completableshould wait for the termination of all mappedCompletables when any one of them terminates with a failure,flatMapCompletableDelayError(Function)should be used.This method is similar to
map(Function)but the result is asynchronous, and provides a data transformation in sequential programming similar to:ExecutorService e = ...; List<Future<Void>> futures = ...; // assume this is thread safe for (T t : resultOfThisPublisher()) { // Note that flatMap process results in parallel. futures.add(e.submit(() -> { return mapper.apply(t); // Asynchronous result is flatten into a value by this operator. })); } // This is an approximation, this operator does not provide any ordering guarantees for the results. for (Future<R> future : futures) { future.get(); // Throws if the processing for this item failed. }- Parameters:
mapper- Function to convert each item emitted by thisPublisherinto aCompletable.maxConcurrency- Maximum activeCompletables at any time.- Returns:
- A new
Completablethat terminates successfully if all the intermediateCompletables have terminated successfully or any one of them has terminated with a failure. - See Also:
- ReactiveX flatMap operator.,
flatMapCompletable(Function),flatMapCompletableDelayError(Function, int)
-
flatMapCompletableDelayError
public final Completable flatMapCompletableDelayError(java.util.function.Function<? super T,? extends Completable> mapper)
Map each element of thisPublisherinto aCompletableand flatten all signals such that the returnedCompletableterminates when all mappedCompletables have terminated successfully or any one of them has terminated with a failure.If any mapped
Completableterminates with an error the returnedCompletablewill not immediately terminate. Instead, it will wait for thisPublisherand all mappedCompletables to terminate.To control the amount of concurrent processing done by this operator see
flatMapCompletableDelayError(Function, int).This method is similar to
map(Function)but the result is asynchronous, and provides a data transformation in sequential programming similar to:Executor e = ...; List<Throwable> errors = ...; // assume this is thread safe CountDownLatch latch = new CountDownLatch(tResults.size()); for (T t : tResults) { // Note that flatMap process results in parallel. e.execute(() -> { try { mapper.apply(t); // Asynchronous result is flattened by this operator. } catch (Throwable cause) { errors.add(cause); // Asynchronous error is flatten into an error by this operator. } finally { latch.countdown(); } }); } latch.await(); if (!errors.isEmpty()) { createAndThrowACompositeException(errors); }- Parameters:
mapper- Function to convert each item emitted by thisPublisherinto aCompletable.- Returns:
- A new
Completablethat terminates successfully if all the intermediateCompletables have terminated successfully or any one of them has terminated with a failure. - See Also:
- ReactiveX merge operator.,
flatMapMergeSingleDelayError(Function, int)
-
flatMapCompletableDelayError
public final Completable flatMapCompletableDelayError(java.util.function.Function<? super T,? extends Completable> mapper, int maxConcurrency)
Map each element of thisPublisherinto aCompletableand flatten all signals such that the returnedCompletableterminates when all mappedCompletables have terminated successfully or any one of them has terminated with a failure.If any mapped
Completableterminates with an error the returnedCompletablewill not immediately terminate. Instead, it will wait for thisPublisherand all mappedCompletables to terminate.This method is similar to
map(Function)but the result is asynchronous, and provides a data transformation in sequential programming similar to:Executor e = ...; List<Throwable> errors = ...; // assume this is thread safe CountDownLatch latch = new CountDownLatch(tResults.size()); for (T t : tResults) { // Note that flatMap process results in parallel. e.execute(() -> { try { mapper.apply(t); // Asynchronous result is flattened by this operator. } catch (Throwable cause) { errors.add(cause); // Asynchronous error is flatten into an error by this operator. } finally { latch.countdown(); } }); } latch.await(); if (!errors.isEmpty()) { createAndThrowACompositeException(errors); }- Parameters:
mapper- Function to convert each item emitted by thisPublisherinto aCompletable.maxConcurrency- Maximum activeCompletables at any time.- Returns:
- A new
Completablethat terminates successfully if all the intermediateCompletables have terminated successfully or any one of them has terminated with a failure. - See Also:
- ReactiveX merge operator.,
flatMapMergeSingleDelayError(Function, int)
-
flatMapCompletableDelayError
public final Completable flatMapCompletableDelayError(java.util.function.Function<? super T,? extends Completable> mapper, int maxConcurrency, int maxDelayedErrorsHint)
Map each element of thisPublisherinto aCompletableand flatten all signals such that the returnedCompletableterminates when all mappedCompletables have terminated successfully or any one of them has terminated with a failure.If any mapped
Completableterminates with an error the returnedCompletablewill not immediately terminate. Instead, it will wait for thisPublisherand all mappedCompletables to terminate.This method is similar to
map(Function)but the result is asynchronous, and provides a data transformation in sequential programming similar to:Executor e = ...; List<Throwable> errors = ...; // assume this is thread safe CountDownLatch latch = new CountDownLatch(tResults.size()); for (T t : tResults) { // Note that flatMap process results in parallel. e.execute(() -> { try { mapper.apply(t); // Asynchronous result is flattened by this operator. } catch (Throwable cause) { errors.add(cause); // Asynchronous error is flatten into an error by this operator. } finally { latch.countdown(); } }); } latch.await(); if (!errors.isEmpty()) { createAndThrowACompositeException(errors); }- Parameters:
mapper- Function to convert each item emitted by thisPublisherinto aCompletable.maxConcurrency- Maximum activeCompletables at any time.maxDelayedErrorsHint- The maximum amount of errors that will be queued. After this point exceptions maybe discarded to reduce memory consumption.- Returns:
- A new
Completablethat terminates successfully if all the intermediateCompletables have terminated successfully or any one of them has terminated with a failure. - See Also:
- ReactiveX merge operator.,
flatMapMergeSingleDelayError(Function, int)
-
flatMapConcatIterable
public final <R> Publisher<R> flatMapConcatIterable(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> mapper)
Create aPublisherthat flattens each element returned by theIterable.iterator()frommapper.The mapper
Functionwill only be called when the previously returnedIteratorhas returnedfalsefromIterator.hasNext().This method provides similar capabilities as expanding each result into a collection and concatenating each collection in sequential programming:
List<R> results = ...; for (T t : resultOfThisPublisher()) { Iterable<? extends R> itr = mapper.apply(t); itr.forEach(results::add); } return results;- Type Parameters:
R- The elements returned by theIterable.- Parameters:
mapper- AFunctionthat returns anIterablefor each element.- Returns:
- a
Publisherthat flattens each element returned by theIterable.iterator()frommapper. The results will be sequential for eachIterator, and overall for all calls toIterable.iterator()
-
whenOnSubscribe
public final Publisher<T> whenOnSubscribe(java.util.function.Consumer<? super PublisherSource.Subscription> onSubscribe)
Invokes theonSubscribeConsumerargument whenPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is called forPublisherSource.Subscribers of the returnedPublisher.The order in which
onSubscribewill be invoked relative toPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is undefined. If you need strict ordering seebeforeOnSubscribe(Consumer)andafterOnSubscribe(Consumer).- Parameters:
onSubscribe- Invoked whenPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is called forPublisherSource.Subscribers of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
beforeOnNext(Consumer),afterOnNext(Consumer)
-
whenOnNext
public final Publisher<T> whenOnNext(java.util.function.Consumer<? super T> onNext)
Invokes theonNextConsumerargument whenPublisherSource.Subscriber.onNext(Object)is called forPublisherSource.Subscribers of the returnedPublisher.The order in which
onNextwill be invoked relative toPublisherSource.Subscriber.onNext(Object)is undefined. If you need strict ordering seebeforeOnNext(Consumer)andafterOnNext(Consumer).From a sequential programming point of view this method is roughly equivalent to the following:
for (T t: resultOfThisPublisher()) { // NOTE: The order of operations here is not guaranteed by this method! processNext(t); onNext.accept(t); }- Parameters:
onNext- Invoked whenPublisherSource.Subscriber.onNext(Object)is called forPublisherSource.Subscribers of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
beforeOnNext(Consumer),afterOnNext(Consumer)
-
whenOnComplete
public final Publisher<T> whenOnComplete(java.lang.Runnable onComplete)
Invokes theonCompleteRunnableargument whenPublisherSource.Subscriber.onComplete()is called forPublisherSource.Subscribers of the returnedPublisher.The order in which
onCompletewill be invoked relative toPublisherSource.Subscriber.onComplete()is undefined. If you need strict ordering seebeforeOnComplete(Runnable)andafterOnComplete(Runnable).From a sequential programming point of view this method is roughly equivalent to the following:
List<T> results = resultOfThisPublisher(); // NOTE: The order of operations here is not guaranteed by this method! onSuccess.accept(results); nextOperation(results);- Parameters:
onComplete- Invoked whenPublisherSource.Subscriber.onComplete()is called forPublisherSource.Subscribers of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
beforeOnComplete(Runnable),afterOnComplete(Runnable)
-
whenOnError
public final Publisher<T> whenOnError(java.util.function.Consumer<java.lang.Throwable> onError)
Invokes theonErrorConsumerargument whenPublisherSource.Subscriber.onError(Throwable)is called forPublisherSource.Subscribers of the returnedPublisher.The order in which
onErrorwill be invoked relative toPublisherSource.Subscriber.onError(Throwable)is undefined. If you need strict ordering seebeforeOnError(Consumer)andafterOnError(Consumer).From a sequential programming point of view this method is roughly equivalent to the following:
try { List<T> results = resultOfThisPublisher(); } catch (Throwable cause) { // NOTE: The order of operations here is not guaranteed by this method! nextOperation(cause); onError.accept(cause); }- Parameters:
onError- Invoked beforePublisherSource.Subscriber.onError(Throwable)is called forPublisherSource.Subscribers of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
beforeOnError(Consumer),afterOnError(Consumer)
-
whenFinally
public final Publisher<T> whenFinally(java.lang.Runnable doFinally)
Invokes thewhenFinallyRunnableargument exactly once, when any of the following terminal methods are called:PublisherSource.Subscriber.onComplete()PublisherSource.Subscriber.onError(Throwable)Cancellable.cancel()
PublisherSource.Subscriptions/PublisherSource.Subscribers of the returnedPublisher.The order in which
whenFinallywill be invoked relative to the above methods is undefined. If you need strict ordering seebeforeFinally(Runnable)andafterFinally(Runnable).From a sequential programming point of view this method is roughly equivalent to the following:
try { List<T> results = resultOfThisPublisher(); } finally { // NOTE: The order of operations here is not guaranteed by this method! nextOperation(); // Maybe notifying of cancellation, or termination doFinally.run(); }- Parameters:
doFinally- Invoked exactly once, when any of the following terminal methods are called:PublisherSource.Subscriber.onComplete()PublisherSource.Subscriber.onError(Throwable)Cancellable.cancel()
PublisherSource.Subscriptions/PublisherSource.Subscribers of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
beforeFinally(Runnable),afterFinally(Runnable)
-
whenFinally
public final Publisher<T> whenFinally(TerminalSignalConsumer doFinally)
Invokes the corresponding method onwhenFinallyTerminalSignalConsumerargument when any of the following terminal methods are called:PublisherSource.Subscriber.onComplete()- invokesTerminalSignalConsumer.onComplete()PublisherSource.Subscriber.onError(Throwable)- invokesTerminalSignalConsumer.onError(Throwable)Cancellable.cancel()- invokesTerminalSignalConsumer.cancel()
PublisherSource.Subscriptions/PublisherSource.Subscribers of the returnedPublisher.The order in which
whenFinallywill be invoked relative to the above methods is undefined. If you need strict ordering seebeforeFinally(TerminalSignalConsumer)andafterFinally(TerminalSignalConsumer).From a sequential programming point of view this method is roughly equivalent to the following:
try { List<T> results = resultOfThisPublisher(); } catch(Throwable t) { // NOTE: The order of operations here is not guaranteed by this method! nextOperation(); // Maybe notifying of cancellation, or termination doFinally.onError(t); return; } // NOTE: The order of operations here is not guaranteed by this method! nextOperation(); // Maybe notifying of cancellation, or termination doFinally.onComplete();- Parameters:
doFinally- For each subscribe of the returnedPublisher, at most one method of thisTerminalSignalConsumerwill be invoked.- Returns:
- The new
Publisher. - See Also:
beforeFinally(TerminalSignalConsumer),afterFinally(TerminalSignalConsumer)
-
whenRequest
public final Publisher<T> whenRequest(java.util.function.LongConsumer onRequest)
Invokes theonRequestLongConsumerargument whenPublisherSource.Subscription.request(long)is called forPublisherSource.Subscriptions of the returnedPublisher.- Parameters:
onRequest- Invoked whenPublisherSource.Subscription.request(long)is called forPublisherSource.Subscriptions of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
whenCancel
public final Publisher<T> whenCancel(java.lang.Runnable onCancel)
Invokes theonCancelRunnableargument whenCancellable.cancel()is called for Subscriptions of the returnedPublisher.The order in which
whenFinallywill be invoked relative toCancellable.cancel()is undefined. If you need strict ordering seebeforeCancel(Runnable)andafterCancel(Runnable).- Parameters:
onCancel- Invoked whenCancellable.cancel()is called for Subscriptions of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
beforeCancel(Runnable),afterCancel(Runnable)
-
idleTimeout
@Deprecated public final Publisher<T> idleTimeout(long duration, java.util.concurrent.TimeUnit unit)
Deprecated.Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between adjacentPublisherSource.Subscriber.onNext(Object)calls. The timer starts when the returnedPublisheris subscribed.In the event of timeout any
PublisherSource.SubscriptionfromPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)will becancelledand the associatedPublisherSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse betweenPublisherSource.Subscriber.onNext(Object)calls.unit- The units forduration.- Returns:
- a new
Publisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses betweenPublisherSource.Subscriber.onNext(Object)calls. - See Also:
- ReactiveX timeout operator.,
timeout(long, TimeUnit, io.servicetalk.concurrent.Executor)
-
idleTimeout
@Deprecated public final Publisher<T> idleTimeout(java.time.Duration duration)
Deprecated.Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between adjacentPublisherSource.Subscriber.onNext(Object)calls. The timer starts when the returnedPublisheris subscribed.In the event of timeout any
PublisherSource.SubscriptionfromPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)will becancelledand the associatedPublisherSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse betweenPublisherSource.Subscriber.onNext(Object)calls.- Returns:
- a new
Publisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses betweenPublisherSource.Subscriber.onNext(Object)calls. - See Also:
- ReactiveX timeout operator.,
timeout(long, TimeUnit, io.servicetalk.concurrent.Executor)
-
idleTimeout
@Deprecated public final Publisher<T> idleTimeout(long duration, java.util.concurrent.TimeUnit unit, Executor timeoutExecutor)
Deprecated.Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between adjacentPublisherSource.Subscriber.onNext(Object)calls. The timer starts when the returnedPublisheris subscribed.In the event of timeout any
PublisherSource.SubscriptionfromPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)will becancelledand the associatedPublisherSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse betweenPublisherSource.Subscriber.onNext(Object)calls.unit- The units forduration.timeoutExecutor- TheExecutorto use for managing the timer notifications.- Returns:
- a new
Publisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses betweenPublisherSource.Subscriber.onNext(Object)calls. - See Also:
- ReactiveX timeout operator.
-
idleTimeout
@Deprecated public final Publisher<T> idleTimeout(java.time.Duration duration, Executor timeoutExecutor)
Deprecated.Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between adjacentPublisherSource.Subscriber.onNext(Object)calls. The timer starts when the returnedPublisheris subscribed.In the event of timeout any
PublisherSource.SubscriptionfromPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)will becancelledand the associatedPublisherSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse betweenPublisherSource.Subscriber.onNext(Object)calls.timeoutExecutor- TheExecutorto use for managing the timer notifications.- Returns:
- a new
Publisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses betweenPublisherSource.Subscriber.onNext(Object)calls. - See Also:
- ReactiveX timeout operator.
-
timeout
public final Publisher<T> timeout(long duration, java.util.concurrent.TimeUnit unit)
Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between adjacentPublisherSource.Subscriber.onNext(Object)calls. The timer starts when the returnedPublisheris subscribed.In the event of timeout any
PublisherSource.SubscriptionfromPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)will becancelledand the associatedPublisherSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse betweenPublisherSource.Subscriber.onNext(Object)calls.unit- The units forduration.- Returns:
- a new
Publisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses betweenPublisherSource.Subscriber.onNext(Object)calls. - See Also:
- ReactiveX timeout operator.,
timeout(long, TimeUnit, io.servicetalk.concurrent.Executor)
-
timeout
public final Publisher<T> timeout(java.time.Duration duration)
Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between adjacentPublisherSource.Subscriber.onNext(Object)calls. The timer starts when the returnedPublisheris subscribed.In the event of timeout any
PublisherSource.SubscriptionfromPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)will becancelledand the associatedPublisherSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse betweenPublisherSource.Subscriber.onNext(Object)calls.- Returns:
- a new
Publisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses betweenPublisherSource.Subscriber.onNext(Object)calls. - See Also:
- ReactiveX timeout operator.,
timeout(long, TimeUnit, io.servicetalk.concurrent.Executor)
-
timeout
public final Publisher<T> timeout(long duration, java.util.concurrent.TimeUnit unit, Executor timeoutExecutor)
Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between adjacentPublisherSource.Subscriber.onNext(Object)calls. The timer starts when the returnedPublisheris subscribed.In the event of timeout any
PublisherSource.SubscriptionfromPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)will becancelledand the associatedPublisherSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse betweenPublisherSource.Subscriber.onNext(Object)calls.unit- The units forduration.timeoutExecutor- TheExecutorto use for managing the timer notifications.- Returns:
- a new
Publisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses betweenPublisherSource.Subscriber.onNext(Object)calls. - See Also:
- ReactiveX timeout operator.
-
timeout
public final Publisher<T> timeout(java.time.Duration duration, Executor timeoutExecutor)
Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between adjacentPublisherSource.Subscriber.onNext(Object)calls. The timer starts when the returnedPublisheris subscribed.In the event of timeout any
PublisherSource.SubscriptionfromPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)will becancelledand the associatedPublisherSource.Subscriberwill beterminated.- Parameters:
duration- The time duration which is allowed to elapse betweenPublisherSource.Subscriber.onNext(Object)calls.timeoutExecutor- TheExecutorto use for managing the timer notifications.- Returns:
- a new
Publisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses betweenPublisherSource.Subscriber.onNext(Object)calls. - See Also:
- ReactiveX timeout operator.
-
timeoutTerminal
public final Publisher<T> timeoutTerminal(java.time.Duration duration)
Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. The timer starts when the returnedPublisheris subscribed.In the event of timeout any
PublisherSource.SubscriptionfromPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)will becancelledand the associatedPublisherSource.Subscriberwill beterminated.- Parameters:
duration- The time duration during which the Publisher must complete.- Returns:
- a new
Publisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. - See Also:
- ReactiveX timeout operator.
-
timeoutTerminal
public final Publisher<T> timeoutTerminal(java.time.Duration duration, Executor timeoutExecutor)
Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. The timer starts when the returnedPublisheris subscribed.In the event of timeout any
PublisherSource.SubscriptionfromPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)will becancelledand the associatedPublisherSource.Subscriberwill beterminated.- Parameters:
duration- The time duration during which the Publisher must complete.timeoutExecutor- TheExecutorto use for managing the timer notifications.- Returns:
- a new
Publisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. - See Also:
- ReactiveX timeout operator.
-
timeoutTerminal
public final Publisher<T> timeoutTerminal(long duration, java.util.concurrent.TimeUnit unit)
Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. The timer starts when the returnedPublisheris subscribed.In the event of timeout any
PublisherSource.SubscriptionfromPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)will becancelledand the associatedPublisherSource.Subscriberwill beterminated.- Parameters:
duration- The time duration during which the Publisher must complete.unit- The units forduration.- Returns:
- a new
Publisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. - See Also:
- ReactiveX timeout operator.
-
timeoutTerminal
public final Publisher<T> timeoutTerminal(long duration, java.util.concurrent.TimeUnit unit, Executor timeoutExecutor)
Creates a newPublisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. The timer starts when the returnedPublisheris subscribed.In the event of timeout any
PublisherSource.SubscriptionfromPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)will becancelledand the associatedPublisherSource.Subscriberwill beterminated.- Parameters:
duration- The time duration during which the Publisher must complete.unit- The units forduration.timeoutExecutor- TheExecutorto use for managing the timer notifications.- Returns:
- a new
Publisherthat will mimic the signals of thisPublisherbut will terminate with aTimeoutExceptionif timedurationelapses between subscribe and termination. - See Also:
- ReactiveX timeout operator.
-
concat
public final Publisher<T> concat(Publisher<? extends T> next)
Emits items emitted bynextPublisherafterthisPublisherterminates successfully.This method provides a means to sequence the execution of two asynchronous sources and in sequential programming is similar to:
List<T> results = resultOfThisPublisher(); results.addAll(resultOfPublisher(next)); return results;
-
concat
public final Publisher<T> concat(Single<? extends T> next)
Listens and emits the result ofnextSingleafterthisPublisherterminates successfully.This method provides a means to sequence the execution of two asynchronous sources and in sequential programming is similar to:
List<T> results = resultOfThisPublisher(); results.add(resultOfSingle(next)); return results;
-
concat
public final Publisher<T> concat(Completable next)
Listens for completion ofnextCompletableafterthisPublisherterminates successfully. Any error fromthisPublisherandnextCompletableis forwarded to the returnedPublisher.This method provides a means to sequence the execution of two asynchronous sources and in sequential programming is similar to:
List<T> results = resultOfThisPublisher(); resultOfCompletable(next); return results;- Parameters:
next-Completableto wait for completion afterthisPublisherterminates successfully.- Returns:
- A
Publisherthat emits all items from thisPublisherand then awaits successful completion ofnextCompletable. - See Also:
- ReactiveX concat operator.
-
retry
public final Publisher<T> retry(BiIntPredicate<java.lang.Throwable> shouldRetry)
Re-subscribes to thisPublisherif an error is emitted and the passedBiIntPredicatereturnstrue.This method provides a means to retry an operation under certain failure conditions and in sequential programming is similar to:
public List<T> execute() { List<T> results = ...; return execute(0, results); } private List<T> execute(int attempts, List<T> results) { try { Iterator<T> itr = resultOfThisPublisher(); while (itr.hasNext()) { T t = itr.next(); // Any iteration with the Iterator may throw results.add(t); } return results; } catch (Throwable cause) { if (shouldRetry.apply(attempts + 1, cause)) { return execute(attempts + 1, results); } else { throw cause; } } }- Parameters:
shouldRetry-BiIntPredicatethat given the retry count and the most recentThrowableemitted from thisPublisherdetermines if the operation should be retried.- Returns:
- A
Publisherthat emits all items from thisPublisherand re-subscribes if an error is emitted if the passedBiIntPredicatereturnedtrue. - See Also:
- ReactiveX retry operator.
-
retryWhen
public final Publisher<T> retryWhen(BiIntFunction<java.lang.Throwable,? extends Completable> retryWhen)
Re-subscribes to thisPublisherif an error is emitted and theCompletablereturned by the suppliedBiIntFunctioncompletes successfully. If the returnedCompletableemits an error, the returnedPublisherterminates with that error.This method provides a means to retry an operation under certain failure conditions in an asynchronous fashion and in sequential programming is similar to:
public List<T> execute() { List<T> results = ...; return execute(0, results); } private List<T> execute(int attempts, List<T> results) { try { Iterator<T> itr = resultOfThisPublisher(); while (itr.hasNext()) { T t = itr.next(); // Any iteration with the Iterator may throw results.add(t); } return results; } catch (Throwable cause) { try { shouldRetry.apply(attempts + 1, cause); // Either throws or completes normally execute(attempts + 1, results); } catch (Throwable ignored) { throw cause; } } }- Parameters:
retryWhen-BiIntFunctionthat given the retry count and the most recentThrowableemitted from thisPublisherreturns aCompletable. If thisCompletableemits an error, that error is emitted from the returnedPublisher, otherwise, originalPublisheris re-subscribed when thisCompletablecompletes.- Returns:
- A
Publisherthat emits all items from thisPublisherand re-subscribes if an error is emitted andCompletablereturned byBiIntFunctioncompletes successfully. - See Also:
- ReactiveX retry operator.
-
repeat
public final Publisher<T> repeat(java.util.function.IntPredicate shouldRepeat)
Re-subscribes to thisPublisherwhen it completes and the passedIntPredicatereturnstrue.This method provides a means to repeat an operation multiple times and in sequential programming is similar to:
List<T> results = new ...; int i = 0; do { results.addAll(resultOfThisPublisher()); } while (shouldRepeat.test(++i)); return results;- Parameters:
shouldRepeat-IntPredicatethat given the repeat count determines if the operation should be repeated.- Returns:
- A
Publisherthat emits all items from thisPublisherand re-subscribes when it completes if the passedIntPredicatereturnstrue. - See Also:
- ReactiveX repeat operator.
-
repeatWhen
public final Publisher<T> repeatWhen(java.util.function.IntFunction<? extends Completable> repeatWhen)
Re-subscribes to thisPublisherwhen it completes and theCompletablereturned by the suppliedIntFunctioncompletes successfully. If the returnedCompletableemits an error, the returnedPublisheris completed.This method provides a means to repeat an operation multiple times when in an asynchronous fashion and in sequential programming is similar to:
List<T> results = new ...; int i = 0; while (true) { results.addAll(resultOfThisPublisher()); try { repeatWhen.apply(++i); // Either throws or completes normally } catch (Throwable cause) { break; } } return results;- Parameters:
repeatWhen-IntFunctionthat given the repeat count returns aCompletable. If thisCompletableemits an error repeat is terminated, otherwise, originalPublisheris re-subscribed when thisCompletablecompletes.- Returns:
- A
Publisherthat emits all items from thisPublisherand re-subscribes if an error is emitted andCompletablereturned byIntFunctioncompletes successfully. - See Also:
- ReactiveX retry operator.
-
takeAtMost
public final Publisher<T> takeAtMost(long numElements)
Takes at mostnumElementselements fromthisPublisher.If no terminal event is received before receiving
numElementselements,PublisherSource.Subscriptionfor thePublisherSource.Subscriberis cancelled.This method provides a means to take a limited number of results from this
Publisherand in sequential programming is similar to:List<T> results = ...; int i = 0; for (T t : resultOfThisPublisher()) { if (++i > numElements) { break; } results.add(t); } return results;- Parameters:
numElements- Number of elements to take.- Returns:
- A
Publisherthat emits at mostnumElementselements fromthisPublisher. - See Also:
- ReactiveX take operator.
-
takeWhile
public final Publisher<T> takeWhile(java.util.function.Predicate<? super T> predicate)
Takes elements whilePredicateistrueand then cancelPublisherSource.Subscriptionof thisPublisheronce it returnsfalse.This method provides a means to take a limited number of results from this
Publisherand in sequential programming is similar to:List<T> results = ...; for (T t : resultOfThisPublisher()) { if (!predicate.test(result)) { break; } results.add(t); } return results;- Parameters:
predicate-Predicatethat is checked before emitting any item to aPublisherSource.Subscriber. If this predicate returnstrue, that item is emitted, elsePublisherSource.Subscriptionis cancelled.- Returns:
- A
Publisherthat only emits the items as long as thePredicate.test(Object)method returnstrue. - See Also:
- ReactiveX takeWhile operator.
-
takeUntil
public final Publisher<T> takeUntil(Completable until)
Takes elements untilCompletableis terminated successfully or with failure.This method provides a means to take a limited number of results from this
Publisherand in sequential programming is similar to:List<T> results = ...; for (T t : resultOfThisPublisher()) { if (isCompleted(until)) { break; } takeResults.add(t); } return results;- Parameters:
until-Completable, termination of which, terminates the returnedPublisher.- Returns:
- A
Publisherthat only emits the items tilluntilCompletableis completed. - See Also:
- ReactiveX takeUntil operator.
-
groupBy
public final <Key> Publisher<GroupedPublisher<Key,T>> groupBy(java.util.function.Function<? super T,? extends Key> keySelector, int groupMaxQueueSize)
Splits items from thisPublisherinto dynamically generatedGroupedPublishers. Item to group association is done bykeySelectorFunction. If the selector selects a key which is previously seen and its associatedPublisherSource.Subscriberhas not yet cancelled itsPublisherSource.Subscription, this item is sent to thatPublisherSource.Subscriber. Otherwise a newGroupedPublisheris created and emitted from the returnedPublisher.Flow control
MultiplePublisherSource.Subscribers (for multipleGroupedPublishers) request items individually from thisPublisher. Since, there is no way for aPublisherSource.Subscriberto only request elements for its group, elements requested by one group may end up producing items for a different group, which has not yet requested enough. This will cause items to be queued per group which can not be emitted due to lack of demand. This queue size can be controlled with themaxQueuePerGroupargument.Cancellation
If thePublisherSource.Subscriberof the returnedPublishercancels itsPublisherSource.Subscription, then all activeGroupedPublishers will be terminated with an error and thePublisherSource.Subscriptionto thisPublisherwill be cancelled.PublisherSource.Subscribers of individualGroupedPublishers can cancel theirPublisherSource.Subscriptions at any point. If any new item is emitted for the cancelledGroupedPublisher, a newGroupedPublisherwill be emitted from the returnedPublisher. Any queued items for a cancelledPublisherSource.Subscriberfor aGroupedPublisherwill be discarded and hence will not be emitted if the sameGroupedPublisheris emitted again.In sequential programming this is similar to the following:
Map<Key, List<T>> results = ...; for (T t : resultOfThisPublisher()) { Key k = keySelector.apply(result); List<T> v = results.get(k); if (v == null) { v = // new List results.put(k, v); } v.add(result); } return results;- Type Parameters:
Key- Type ofGroupedPublisherkeys.- Parameters:
keySelector-Functionto assign an item emitted by thisPublisherto aGroupedPublisher.groupMaxQueueSize- Maximum number of new groups that will be queued due to thePublisherSource.Subscriberof thePublisherreturned from this method not requesting enough viaPublisherSource.Subscription.request(long).- Returns:
- A
Publisherthat emitsGroupedPublishers for newkeys as emitted bykeySelectorFunction. - See Also:
- ReactiveX groupBy operator.
-
groupBy
public final <Key> Publisher<GroupedPublisher<Key,T>> groupBy(java.util.function.Function<? super T,? extends Key> keySelector, int groupMaxQueueSize, int expectedGroupCountHint)
Splits items from thisPublisherinto dynamically generatedGroupedPublishers. Item to group association is done bykeySelectorFunction. If the selector selects a key which is previously seen and its associatedPublisherSource.Subscriberhas not yet cancelled itsPublisherSource.Subscription, this item is sent to thatPublisherSource.Subscriber. Otherwise a newGroupedPublisheris created and emitted from the returnedPublisher.Flow control
MultiplePublisherSource.Subscribers (for multipleGroupedPublishers) request items individually from thisPublisher. Since, there is no way for aPublisherSource.Subscriberto only request elements for its group, elements requested by one group may end up producing items for a different group, which has not yet requested enough. This will cause items to be queued per group which can not be emitted due to lack of demand. This queue size can be controlled with themaxQueuePerGroupargument.Cancellation
If thePublisherSource.Subscriberof the returnedPublishercancels itsPublisherSource.Subscription, then all activeGroupedPublishers will be terminated with an error and thePublisherSource.Subscriptionto thisPublisherwill be cancelled.PublisherSource.Subscribers of individualGroupedPublishers can cancel theirPublisherSource.Subscriptions at any point. If any new item is emitted for the cancelledGroupedPublisher, a newGroupedPublisherwill be emitted from the returnedPublisher. Any queued items for a cancelledPublisherSource.Subscriberfor aGroupedPublisherwill be discarded and hence will not be emitted if the sameGroupedPublisheris emitted again.In sequential programming this is similar to the following:
Map<Key, List<T>> results = ...; for (T t : resultOfThisPublisher()) { Key k = keySelector.apply(result); List<T> v = results.get(k); if (v == null) { v = // new List results.put(k, v); } v.add(result); } return results;- Type Parameters:
Key- Type ofGroupedPublisherkeys.- Parameters:
keySelector-Functionto assign an item emitted by thisPublisherto aGroupedPublisher.groupMaxQueueSize- Maximum number of new groups that will be queued due to thePublisherSource.Subscriberof thePublisherreturned from this method not requesting enough viaPublisherSource.Subscription.request(long).expectedGroupCountHint- Expected number of groups that would be emitted bythisPublisher. This is just a hint for internal data structures and does not have to be precise.- Returns:
- A
Publisherthat emitsGroupedPublishers for newkeys as emitted bykeySelectorFunction. - See Also:
- ReactiveX groupBy operator.
-
groupToMany
public final <Key> Publisher<GroupedPublisher<Key,T>> groupToMany(java.util.function.Function<? super T,? extends java.util.Iterator<? extends Key>> keySelector, int groupMaxQueueSize)
The semantics are identical togroupBy(Function, int)except that thekeySelectorcan map each data to multiple keys.In sequential programming this is similar to the following:
Map<Key, List<T>> results = ...; for (T t : resultOfThisPublisher()) { Iterator<Key> keys = keySelector.apply(result); for (Key key : keys) { List<T> v = results.get(key); if (v == null) { v = // new List results.put(key, v); } v.add(result); } } return results;- Type Parameters:
Key- Type ofGroupedPublisherkeys.- Parameters:
keySelector-Functionto assign an item emitted by thisPublisherto multipleGroupedPublishers.groupMaxQueueSize- Maximum number of new groups that will be queued due to thePublisherSource.Subscriberof thePublisherreturned from this method not requesting enough viaPublisherSource.Subscription.request(long).- Returns:
- A
Publisherthat emitsGroupedPublishers for newkeys as emitted bykeySelectorFunction. - See Also:
groupBy(Function, int)
-
groupToMany
public final <Key> Publisher<GroupedPublisher<Key,T>> groupToMany(java.util.function.Function<? super T,? extends java.util.Iterator<? extends Key>> keySelector, int groupMaxQueueSize, int expectedGroupCountHint)
The semantics are identical togroupBy(Function, int)except that thekeySelectorcan map each data to multiple keys.In sequential programming this is similar to the following:
Map<Key, List<T>> results = ...; for (T t : resultOfThisPublisher()) { Iterator<Key> keys = keySelector.apply(result); for (Key key : keys) { List<T> v = results.get(key); if (v == null) { v = // new List results.put(key, v); } v.add(result); } } return results;- Type Parameters:
Key- Type ofGroupedPublisherkeys.- Parameters:
keySelector-Functionto assign an item emitted by thisPublisherto multipleGroupedPublishers.groupMaxQueueSize- Maximum number of new groups that will be queued due to thePublisherSource.Subscriberof thePublisherreturned from this method not requesting enough viaPublisherSource.Subscription.request(long).expectedGroupCountHint- Expected number of groups that would be emitted bythisPublisher. This is just a hint for internal data structures and does not have to be precise.- Returns:
- A
Publisherthat emitsGroupedPublishers for newkeys as emitted bykeySelectorFunction. - See Also:
groupBy(Function, int)
-
multicastToExactly
public final Publisher<T> multicastToExactly(int expectedSubscribers)
Create aPublisherthat multicasts all the signals to exactlyexpectedSubscribers.Depending on
PublisherSource.Subscription.request(long)demand it is possible that data maybe queued before being delivered to eachPublisherSource.Subscriber! For example if there are 2PublisherSource.Subscribers and the first callsrequest(10), and the second only callsrequest(1), then 9 elements will be queued to deliver to second when morePublisherSource.Subscription.request(long)demand is made.In sequential programming this is similar to the following:
List<T> results = resultOfThisPublisher(); List<List<T>> multiResults = ...; for (int i = 0; i < expectedSubscribers; ++i) { multiResults.add(results); } return multiResults;
-
multicastToExactly
public final Publisher<T> multicastToExactly(int expectedSubscribers, int maxQueueSize)
Create aPublisherthat allows exactlyexpectedSubscriberssubscribes. The events from thisPublisherobject will be delivered to eachPublisherSource.Subscriber.Depending on
PublisherSource.Subscription.request(long)demand it is possible that data maybe queued before being delivered to eachPublisherSource.Subscriber! For example if there are 2PublisherSource.Subscribers and the first callsrequest(10), and the second only callsrequest(10), then 9 elements will be queued to deliver to second when morePublisherSource.Subscription.request(long)demand is made.In sequential programming this is similar to the following:
List<T> results = resultOfThisPublisher(); List<List<T>> multiResults = ...; for (int i = 0; i < expectedSubscribers; ++i) { multiResults.add(results); } return multiResults;- Parameters:
expectedSubscribers- The number of expected subscribe calls required on the returnedPublisherbefore subscribing to thisPublisher.maxQueueSize- The maximum number ofPublisherSource.Subscriber.onNext(Object)events that will be queued if there is no demand for data before thePublisherSource.Subscriberwill be discarded.- Returns:
- a
Publisherthat allows exactlyexpectedSubscriberssubscribes.
-
buffer
public final <BC extends BufferStrategy.Accumulator<T,B>,B> Publisher<B> buffer(BufferStrategy<T,BC,B> strategy)
Create aPublisherthat buffers items from thisPublisherand emit those buffers instead of the individual items.In sequential programming this is similar to the following:
List accumulators = strategy.boundaries(); List buffers = ...; BC currentAccumulator; for (T t : resultOfThisPublisher()) { // This is an approximation; accumulators are emitted asynchronously. BC nextAccumulator = accumulators.remove(0).get(); buffers.add(currentAccumulator.finish()); currentAccumulator = nextAccumulator; currentAccumulator.add(t); } return buffers;- Type Parameters:
BC- Type of theBufferStrategy.Accumulatorto buffer items from thisPublisher.B- Type of the buffer emitted from the returnedPublisher.- Parameters:
strategy- ABufferStrategyto use for buffering items from thisPublisher.- Returns:
- a
Publisherthat buffers items from thisPublisherand emit those buffers instead of the individual items. - See Also:
- ReactiveX buffer operator.
-
beforeOnSubscribe
public final Publisher<T> beforeOnSubscribe(java.util.function.Consumer<? super PublisherSource.Subscription> onSubscribe)
Invokes theonSubscribeConsumerargument beforePublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is called forPublisherSource.Subscribers of the returnedPublisher.- Parameters:
onSubscribe- Invoked beforePublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is called forPublisherSource.Subscribers of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
beforeOnNext
public final Publisher<T> beforeOnNext(java.util.function.Consumer<? super T> onNext)
Invokes theonNextConsumerargument beforePublisherSource.Subscriber.onNext(Object)is called forPublisherSource.Subscribers of the returnedPublisher.From a sequential programming point of view this method is roughly equivalent to the following:
List<T> results = resultOfThisPublisher(); for (T result : results) { onNext.accept(result); } nextOperation(results);- Parameters:
onNext- Invoked beforePublisherSource.Subscriber.onNext(Object)is called forPublisherSource.Subscribers of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
beforeOnError
public final Publisher<T> beforeOnError(java.util.function.Consumer<java.lang.Throwable> onError)
Invokes theonErrorConsumerargument beforePublisherSource.Subscriber.onError(Throwable)is called forPublisherSource.Subscribers of the returnedPublisher.From a sequential programming point of view this method is roughly equivalent to the following:
try { List<T> results = resultOfThisPublisher(); } catch (Throwable cause) { onError.accept(cause); nextOperation(cause); }- Parameters:
onError- Invoked beforePublisherSource.Subscriber.onError(Throwable)is called forPublisherSource.Subscribers of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
beforeOnComplete
public final Publisher<T> beforeOnComplete(java.lang.Runnable onComplete)
Invokes theonCompleteRunnableargument beforePublisherSource.Subscriber.onComplete()is called forPublisherSource.Subscribers of the returnedPublisher.From a sequential programming point of view this method is roughly equivalent to the following:
List<T> results = resultOfThisPublisher(); onComplete.run(); nextOperation(results);- Parameters:
onComplete- Invoked beforePublisherSource.Subscriber.onComplete()is called forPublisherSource.Subscribers of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
beforeRequest
public final Publisher<T> beforeRequest(java.util.function.LongConsumer onRequest)
Invokes theonRequestLongConsumerargument beforePublisherSource.Subscription.request(long)is called forPublisherSource.Subscriptions of the returnedPublisher.- Parameters:
onRequest- Invoked beforePublisherSource.Subscription.request(long)is called forPublisherSource.Subscriptions of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
beforeCancel
public final Publisher<T> beforeCancel(java.lang.Runnable onCancel)
Invokes theonCancelRunnableargument beforeCancellable.cancel()is called forPublisherSource.Subscriptions of the returnedPublisher.- Parameters:
onCancel- Invoked beforeCancellable.cancel()is called forPublisherSource.Subscriptions of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
beforeFinally
public final Publisher<T> beforeFinally(java.lang.Runnable doFinally)
Invokes thebeforeFinallyRunnableargument before any of the following terminal methods are called:PublisherSource.Subscriber.onComplete()PublisherSource.Subscriber.onError(Throwable)Cancellable.cancel()
PublisherSource.Subscriptions/PublisherSource.Subscribers of the returnedPublisher.From a sequential programming point of view this method is roughly equivalent to the following:
try { List<T> results = resultOfThisPublisher(); } finally { doFinally.run(); nextOperation(); // Maybe notifying of cancellation, or termination }- Parameters:
doFinally- Invoked before any of the following terminal methods are called:PublisherSource.Subscriber.onComplete()PublisherSource.Subscriber.onError(Throwable)Cancellable.cancel()
PublisherSource.Subscriptions/PublisherSource.Subscribers of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
beforeFinally
public final Publisher<T> beforeFinally(TerminalSignalConsumer doFinally)
Invokes the corresponding method onbeforeFinallyTerminalSignalConsumerargument before any of the following terminal methods are called:PublisherSource.Subscriber.onComplete()- invokesTerminalSignalConsumer.onComplete()PublisherSource.Subscriber.onError(Throwable)- invokesTerminalSignalConsumer.onError(Throwable)Cancellable.cancel()- invokesTerminalSignalConsumer.cancel()
PublisherSource.Subscriptions/PublisherSource.Subscribers of the returnedPublisher.From a sequential programming point of view this method is roughly equivalent to the following:
try { List<T> results = resultOfThisPublisher(); } catch(Throwable t) { doFinally.onError(t); nextOperation(); // Maybe notifying of cancellation, or termination return; } doFinally.onComplete(); nextOperation(); // Maybe notifying of cancellation, or termination- Parameters:
doFinally- For each subscribe of the returnedPublisher, at most one method of thisTerminalSignalConsumerwill be invoked.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
beforeSubscriber
public final Publisher<T> beforeSubscriber(java.util.function.Supplier<? extends PublisherSource.Subscriber<? super T>> subscriberSupplier)
Creates a newPublisherSource.Subscriber(via thesubscriberSupplierargument) on each call to subscribe and invokes all thePublisherSource.Subscribermethods before thePublisherSource.Subscribers of the returnedPublisher.- Parameters:
subscriberSupplier- Creates a newPublisherSource.Subscriberon each call to subscribe and invokes all thePublisherSource.Subscribermethods before thePublisherSource.Subscribers of the returnedPublisher.PublisherSource.Subscribermethods MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
beforeSubscription
public final Publisher<T> beforeSubscription(java.util.function.Supplier<? extends PublisherSource.Subscription> subscriptionSupplier)
Creates a newPublisherSource.Subscription(via thesubscriptionSupplierargument) on each call to subscribe and invokes all thePublisherSource.Subscriptionmethods before thePublisherSource.Subscriptions of the returnedPublisher.- Parameters:
subscriptionSupplier- Creates a newPublisherSource.Subscriptionon each call to subscribe and invokes all thePublisherSource.Subscriptionmethods before thePublisherSource.Subscriptions of the returnedPublisher.PublisherSource.Subscriptionmethods MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
afterOnSubscribe
public final Publisher<T> afterOnSubscribe(java.util.function.Consumer<? super PublisherSource.Subscription> onSubscribe)
Invokes theonSubscribeConsumerargument afterPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is called forPublisherSource.Subscribers of the returnedPublisher.- Parameters:
onSubscribe- Invoked afterPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is called forPublisherSource.Subscribers of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
afterOnNext
public final Publisher<T> afterOnNext(java.util.function.Consumer<? super T> onNext)
Invokes theonNextConsumerargument afterPublisherSource.Subscriber.onNext(Object)is called forPublisherSource.Subscribers of the returnedPublisher.From a sequential programming point of view this method is roughly equivalent to the following:
List<T> results = resultOfThisPublisher(); nextOperation(results); for (T result : results) { onNext.accept(result); }- Parameters:
onNext- Invoked afterPublisherSource.Subscriber.onNext(Object)is called forPublisherSource.Subscribers of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
afterOnError
public final Publisher<T> afterOnError(java.util.function.Consumer<java.lang.Throwable> onError)
Invokes theonErrorConsumerargument afterPublisherSource.Subscriber.onError(Throwable)is called forPublisherSource.Subscribers of the returnedPublisher.From a sequential programming point of view this method is roughly equivalent to the following:
try { List<T> results = resultOfThisPublisher(); } catch (Throwable cause) { nextOperation(cause); onError.accept(cause); }- Parameters:
onError- Invoked afterPublisherSource.Subscriber.onError(Throwable)is called forPublisherSource.Subscribers of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
afterOnComplete
public final Publisher<T> afterOnComplete(java.lang.Runnable onComplete)
Invokes theonCompleteRunnableargument afterPublisherSource.Subscriber.onComplete()is called forPublisherSource.Subscribers of the returnedPublisher.From a sequential programming point of view this method is roughly equivalent to the following:
List<T> results = resultOfThisPublisher(); nextOperation(results); onComplete.run();- Parameters:
onComplete- Invoked afterPublisherSource.Subscriber.onComplete()is called forPublisherSource.Subscribers of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
afterRequest
public final Publisher<T> afterRequest(java.util.function.LongConsumer onRequest)
Invokes theonRequestLongConsumerargument afterPublisherSource.Subscription.request(long)is called forPublisherSource.Subscriptions of the returnedPublisher.- Parameters:
onRequest- Invoked afterPublisherSource.Subscription.request(long)is called forPublisherSource.Subscriptions of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
afterCancel
public final Publisher<T> afterCancel(java.lang.Runnable onCancel)
Invokes theonCancelRunnableargument afterCancellable.cancel()is called forPublisherSource.Subscriptions of the returnedPublisher.- Parameters:
onCancel- Invoked afterCancellable.cancel()is called forPublisherSource.Subscriptions of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
afterFinally
public final Publisher<T> afterFinally(java.lang.Runnable doFinally)
Invokes theafterFinallyRunnableargument after any of the following terminal methods are called:PublisherSource.Subscriber.onComplete()PublisherSource.Subscriber.onError(Throwable)Cancellable.cancel()
PublisherSource.Subscriptions/PublisherSource.Subscribers of the returnedPublisher.From a sequential programming point of view this method is roughly equivalent to the following:
try { List<T> results = resultOfThisPublisher(); } finally { nextOperation(); // Maybe notifying of cancellation, or termination doFinally.run(); }- Parameters:
doFinally- Invoked after any of the following terminal methods are called:PublisherSource.Subscriber.onComplete()PublisherSource.Subscriber.onError(Throwable)Cancellable.cancel()
PublisherSource.Subscriptions/PublisherSource.Subscribers of the returnedPublisher. MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
afterFinally
public final Publisher<T> afterFinally(TerminalSignalConsumer doFinally)
Invokes the corresponding method onafterFinallyTerminalSignalConsumerargument after any of the following terminal methods are called:PublisherSource.Subscriber.onComplete()- invokesTerminalSignalConsumer.onComplete()PublisherSource.Subscriber.onError(Throwable)- invokesTerminalSignalConsumer.onError(Throwable)Cancellable.cancel()- invokesTerminalSignalConsumer.cancel()
PublisherSource.Subscriptions/PublisherSource.Subscribers of the returnedPublisher.From a sequential programming point of view this method is roughly equivalent to the following:
try { List<T> results = resultOfThisPublisher(); } catch(Throwable t) { nextOperation(); // Maybe notifying of cancellation, or termination doFinally.onError(t); return; } nextOperation(); // Maybe notifying of cancellation, or termination doFinally.onComplete();- Parameters:
doFinally- For each subscribe of the returnedPublisher, at most one method of thisTerminalSignalConsumerwill be invoked.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
afterSubscriber
public final Publisher<T> afterSubscriber(java.util.function.Supplier<? extends PublisherSource.Subscriber<? super T>> subscriberSupplier)
Creates a newPublisherSource.Subscriber(via thesubscriberSupplierargument) for each new subscribe and invokes all thePublisherSource.Subscribermethods after thePublisherSource.Subscribers of the returnedPublisher.- Parameters:
subscriberSupplier- Creates a newPublisherSource.Subscriberfor each new subscribe and invokes all thePublisherSource.Subscribermethods after thePublisherSource.Subscribers of the returnedPublisher.PublisherSource.Subscribermethods MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
whenSubscriber
public final Publisher<T> whenSubscriber(java.util.function.Supplier<? extends PublisherSource.Subscriber<? super T>> subscriberSupplier)
Creates a newPublisherSource.Subscriber(via thesubscriberSupplierargument) for each new subscribe and invokes methods on thatPublisherSource.Subscriberwhen the corresponding methods are called forPublisherSource.Subscribers of the returnedPublisher.- Parameters:
subscriberSupplier- Creates a newPublisherSource.Subscriberfor each new subscribe and invokes methods on thatPublisherSource.Subscriberwhen the corresponding methods are called forPublisherSource.Subscribers of the returnedPublisher.PublisherSource.Subscribermethods MUST NOT throw.- Returns:
- The new
Publisher.
-
afterSubscription
public final Publisher<T> afterSubscription(java.util.function.Supplier<? extends PublisherSource.Subscription> subscriptionSupplier)
Creates a newPublisherSource.Subscription(via thesubscriptionSupplierargument) for each new subscribe and invokes all thePublisherSource.Subscriptionmethods after thePublisherSource.Subscriptions of the returnedPublisher.- Parameters:
subscriptionSupplier- Creates a newPublisherSource.Subscriptionfor each new subscribe and invokes all thePublisherSource.Subscriptionmethods after thePublisherSource.Subscriptions of the returnedPublisher.PublisherSource.Subscriptionmethods MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
whenSubscription
public final Publisher<T> whenSubscription(java.util.function.Supplier<? extends PublisherSource.Subscription> subscriptionSupplier)
Creates a newPublisherSource.Subscription(via thesubscriptionSupplierargument) for each new subscribe and invokes all thePublisherSource.Subscriptionmethods when the corresponding methods are called forPublisherSource.Subscriptions of the returnedPublisher.- Parameters:
subscriptionSupplier- Creates a newPublisherSource.Subscriptionfor each new subscribe and invokes all thePublisherSource.Subscriptionmethods when thePublisherSource.Subscriptions of the returnedPublisher.PublisherSource.Subscriptionmethods MUST NOT throw.- Returns:
- The new
Publisher. - See Also:
- ReactiveX do operator.
-
forEach
public final Cancellable forEach(java.util.function.Consumer<? super T> forEach)
Subscribes to thisPublisherand invokesforEachConsumerfor each item emitted by thisPublisher.This will request
Long.MAX_VALUEfrom thePublisherSource.Subscription.From a sequential programming point of view this method is roughly equivalent to the following:
List<T> results = resultOfThisPublisher(); results.iterator().forEachRemaining(forEach);- Parameters:
forEach-Consumerto invoke for eachPublisherSource.Subscriber.onNext(Object).- Returns:
Cancellableused to invokeCancellable.cancel()on the parameter ofPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)for thisPublisher.
-
publishOn
public final Publisher<T> publishOn(Executor executor)
Creates a newPublisherthat will use the passedExecutorto invoke allPublisherSource.Subscribermethods. This method does not override precedingExecutors, if any, specified forthisPublisher. Only subsequent operations, if any, added in this execution chain will use thisExecutor. If such an override is required,publishOnOverride(Executor)can be used.- Parameters:
executor-Executorto use.- Returns:
- A new
Publisherthat will use the passedExecutorto invoke all methods ofPublisherSource.Subscriber.
-
publishOnOverride
public final Publisher<T> publishOnOverride(Executor executor)
Creates a newPublisherthat will use the passedExecutorto invoke allPublisherSource.Subscribermethods. This method overrides precedingExecutors, if any, specified forthisPublisher. That is to say preceding and subsequent operations for this execution chain will use thisExecutor. If such an override is not required,publishOn(Executor)can be used.
-
subscribeOn
public final Publisher<T> subscribeOn(Executor executor)
Creates a newPublisherthat will use the passedExecutorto invoke the following methods:- All
PublisherSource.Subscriptionmethods. - The
handleSubscribe(PublisherSource.Subscriber)method.
Executors, if any, specified forthisPublisher. Only subsequent operations, if any, added in this execution chain will use thisExecutor. If such an override is required,subscribeOnOverride(Executor)can be used.- Parameters:
executor-Executorto use.- Returns:
- A new
Publisherthat will use the passedExecutorto invoke all methods ofPublisherSource.SubscriptionandhandleSubscribe(PublisherSource.Subscriber).
- All
-
subscribeOnOverride
public final Publisher<T> subscribeOnOverride(Executor executor)
Creates a newPublisherthat will use the passedExecutorto invoke the following methods:- All
PublisherSource.Subscriptionmethods. - The
handleSubscribe(PublisherSource.Subscriber)method.
Executors, if any, specified forthisPublisher. That is to say preceding and subsequent operations for this execution chain will use thisExecutor. If such an override is not required,subscribeOn(Executor)can be used.- Parameters:
executor-Executorto use.- Returns:
- A new
Publisherthat will use the passedExecutorto invoke all methods ofPublisherSource.SubscriptionandhandleSubscribe(PublisherSource.Subscriber)both for the returnedPublisheras well asthisPublisher.
- All
-
publishAndSubscribeOn
public final Publisher<T> publishAndSubscribeOn(Executor executor)
Creates a newPublisherthat will use the passedExecutorto invoke the following methods:- All
PublisherSource.Subscribermethods. - All
PublisherSource.Subscriptionmethods. - The
handleSubscribe(PublisherSource.Subscriber)method.
Executors, if any, specified forthisPublisher. Only subsequent operations, if any, added in this execution chain will use thisExecutor. If such an override is required,publishAndSubscribeOnOverride(Executor)can be used.- Parameters:
executor-Executorto use.- Returns:
- A new
Publisherthat will use the passedExecutorto invoke all methodsPublisherSource.Subscriber,PublisherSource.SubscriptionandhandleSubscribe(PublisherSource.Subscriber).
- All
-
publishAndSubscribeOnOverride
public final Publisher<T> publishAndSubscribeOnOverride(Executor executor)
Creates a newPublisherthat will use the passedExecutorto invoke the following methods:- All
PublisherSource.Subscribermethods. - All
PublisherSource.Subscriptionmethods. - The
handleSubscribe(PublisherSource.Subscriber)method.
Executors, if any, specified forthisPublisher. That is to say preceding and subsequent operations for this execution chain will use thisExecutor. If such an override is not required,publishAndSubscribeOn(Executor)can be used.- Parameters:
executor-Executorto use.- Returns:
- A new
Publisherthat will use the passedExecutorto invoke all methods ofPublisherSource.Subscriber,PublisherSource.SubscriptionandhandleSubscribe(PublisherSource.Subscriber)both for the returnedPublisheras well asthisPublisher.
- All
-
subscribeShareContext
public final Publisher<T> subscribeShareContext()
Signifies that when the returnedPublisheris subscribed to, theAsyncContextwill be shared instead of making acopy.This operator only impacts behavior if the returned
Publisheris subscribed directly after this operator, that means this must be the "last operator" in the chain for this to have an impact.- Returns:
- A
Publisherthat will share theAsyncContextinstead of making acopywhen subscribed to.
-
liftSync
public final <R> Publisher<R> liftSync(PublisherOperator<? super T,? extends R> operator)
This method requires advanced knowledge of building operators. Before using this method please attempt to compose existing operator(s) to satisfy your use case.Returns a
Publisherwhich when subscribed, theoperatorargument will be used to wrap thePublisherSource.Subscriberbefore subscribing to thisPublisher.
ThePublisher<X> pub = ...; pub.map(..) // A .liftSync(original -> modified) .filter(..) // Boriginal -> modified"operator" MUST be "synchronous" in that it does not interact with the originalPublisherSource.Subscriberfrom outside the modifiedPublisherSource.SubscriberorPublisherSource.Subscriptionthreads. That is to say this operator will not impact theExecutorconstraints already in place between A and B above. If you need asynchronous behavior, or are unsure, seeliftAsync(PublisherOperator).- Type Parameters:
R- Type of the items emitted by the returnedPublisher.- Parameters:
operator- The custom operator logic. The input is the "original"PublisherSource.Subscriberto thisPublisherand the return is the "modified"PublisherSource.Subscriberthat provides custom operator business logic.- Returns:
- a
Publisherwhich when subscribed, theoperatorargument will be used to wrap thePublisherSource.Subscriberbefore subscribing to thisPublisher. - See Also:
liftAsync(PublisherOperator)
-
liftSyncToSingle
public final <R> Single<R> liftSyncToSingle(PublisherToSingleOperator<? super T,? extends R> operator)
This method requires advanced knowledge of building operators. Before using this method please attempt to compose existing operator(s) to satisfy your use case.Returns a
Singlewhich when subscribed, theoperatorargument will be used to convert between theSingleSource.Subscriberto aPublisherSource.Subscriberbefore subscribing to thisPublisher.
ThePublisher<X> pub = ...; pub.map(..) // A .liftSync(original -> modified) .filter(..) // B - we have converted to Single now!original -> modified"operator" MUST be "synchronous" in that it does not interact with the originalPublisherSource.Subscriberfrom outside the modifiedPublisherSource.SubscriberorPublisherSource.Subscriptionthreads. That is to say this operator will not impact theExecutorconstraints already in place between A and B above. If you need asynchronous behavior, or are unsure, don't use this operator.- Type Parameters:
R- Type of the items emitted by the returnedSingle.- Parameters:
operator- The custom operator logic. The input is the "original"SingleSource.Subscriberto the returnedSingleand the return is the "modified"PublisherSource.Subscriberthat provides custom operator business logic on thisPublisher.- Returns:
- a
Singlewhich when subscribed, theoperatorargument will be used to convert theSingleSource.Subscriberto aPublisherSource.Subscriberbefore subscribing to thisPublisher.
-
liftAsync
public final <R> Publisher<R> liftAsync(PublisherOperator<? super T,? extends R> operator)
This method requires advanced knowledge of building operators. Before using this method please attempt to compose existing operator(s) to satisfy your use case.Returns a
Publisherwhich will wrap thePublisherSource.Subscriberusing the providedoperatorargument before subscribing to thisPublisher.
ThePublisher<X> pub = ...; pub.map(..) // A .liftAsync(original -> modified) .filter(..) // Boriginal -> modified"operator" MAY be "asynchronous" in that it may interact with the originalPublisherSource.Subscriberfrom outside the modifiedPublisherSource.SubscriberorPublisherSource.Subscriptionthreads. More specifically:- all of the
PublisherSource.Subscriberinvocations going "downstream" (i.e. from A to B above) MAY be offloaded via anExecutor - all of the
PublisherSource.Subscriptioninvocations going "upstream" (i.e. from B to A above) MAY be offloaded via anExecutor
- Type Parameters:
R- Type of the items emitted by the returnedPublisher.- Parameters:
operator- The custom operator logic. The input is the "original"PublisherSource.Subscriberto thisPublisherand the return is the "modified"PublisherSource.Subscriberthat provides custom operator business logic.- Returns:
- a
Publisherwhich when subscribed, theoperatorargument will be used to wrap thePublisherSource.Subscriberbefore subscribing to thisPublisher. - See Also:
liftSync(PublisherOperator)
- all of the
-
firstOrElse
public final Single<T> firstOrElse(java.util.function.Supplier<T> defaultValueSupplier)
- Parameters:
defaultValueSupplier- ASupplierof default value if thisPublisherdid not emit any item.- Returns:
- A
Singlethat will contain the first item emitted from the thisPublisher. If the sourcePublisherdoes not emit any item, then the returnedSinglewill contain the value as returned by the passedSupplier. - See Also:
- ReactiveX first operator.
-
firstOrError
public final Single<T> firstOrError()
Ensures that thisPublisheremits exactly a singlePublisherSource.Subscriber.onNext(Object)to itsPublisherSource.Subscriber. If thisPublisherterminates without emitting any items aNoSuchElementExceptionwill be signaled and if thisPublisheremits more than one item, anIllegalArgumentExceptionwill be signaled. Any error emitted by thisPublisherwill be forwarded to the returnedSingle.
-
ignoreElements
public final Completable ignoreElements()
Ignores all elements emitted by thisPublisherand forwards the termination signal to the returnedCompletable.- Returns:
- A
Completablethat mirrors the terminal signal from thisPublisher. - See Also:
- ReactiveX ignoreElements operator.
-
completableOrError
public final Completable completableOrError()
Converts thisPublisherto aCompletable. If thisPublisheremits anyPublisherSource.Subscriber.onNext(Object)signals the resultingCompletablewill be terminated with aIllegalArgumentException.- Returns:
- A
Completablethat mirrors the terminal signal from thisPublisher, and terminates in error if anPublisherSource.Subscriber.onNext(Object)signals.
-
collect
public final <R> Single<R> collect(java.util.function.Supplier<? extends R> resultFactory, java.util.function.BiFunction<? super R,? super T,R> collector)
Collects all items emitted by thisPublisherinto a single item.- Type Parameters:
R- Type of the reduced item.- Parameters:
resultFactory- Factory for the result which collects all items emitted by thisPublisher. This will be called every time the returnedSingleis subscribed.collector- Invoked for every item emitted by the sourcePublisherand returns the same or alteredresultobject.- Returns:
- A
Singlethat completes with the singleresultor any error emitted by the sourcePublisher. - See Also:
- ReactiveX reduce operator.
-
toFuture
public final java.util.concurrent.Future<java.util.Collection<T>> toFuture()
Convert thisPublisherinto aFuturewith aCollectioncontaining the elements of thisPublisherupon successful termination. If thisPublisherterminates in an error, then the intermediateCollectionwill be discarded and theFuturewill complete exceptionally.- Returns:
- a
Futurewith aCollectioncontaining the elements of thisPublisherupon successful termination. - See Also:
toFuture(Supplier, BiFunction)
-
toFuture
public final <R> java.util.concurrent.Future<R> toFuture(java.util.function.Supplier<? extends R> resultFactory, java.util.function.BiFunction<? super R,? super T,R> reducer)Convert thisPublisherinto aFutureof typePublisherwhich represents all elements of thisPublisherupon successful termination. If thisPublisherterminates in an error, then the intermediatePublisherwill be discarded and theFuturewill complete exceptionally.- Type Parameters:
R- Type of the reduced item.- Parameters:
resultFactory- Factory for the result which collects all items emitted by thisPublisher.reducer- Invoked for every item emitted by the sourcePublisherand returns the same or alteredresultobject.- Returns:
- a
Futureof typePublisherwhich represents all elements of thisPublisherupon successful termination.
-
toCompletionStage
public final java.util.concurrent.CompletionStage<java.util.Collection<T>> toCompletionStage()
Convert thisPublisherinto aCompletionStagewith aCollectioncontaining the elements of thisPublisherupon successful termination. If thisPublisherterminates in an error, then the intermediateCollectionwill be discarded and theCompletionStagewill complete exceptionally.- Returns:
- a
CompletionStagewith aCollectioncontaining the elements of thisPublisherupon successful termination. - See Also:
toCompletionStage(Supplier, BiFunction)
-
toCompletionStage
public final <R> java.util.concurrent.CompletionStage<R> toCompletionStage(java.util.function.Supplier<? extends R> resultFactory, java.util.function.BiFunction<? super R,? super T,R> reducer)Convert thisPublisherinto aCompletionStageof typePublisherwhich represents all elements of thisPublisherupon successful termination. If thisPublisherterminates in an error, then the intermediatePublisherwill be discarded and theCompletionStagewill complete exceptionally.- Type Parameters:
R- Type of the reduced item.- Parameters:
resultFactory- Factory for the result which collects all items emitted by thisPublisher.reducer- Invoked for every item emitted by the sourcePublisherand returns the same or alteredresultobject.- Returns:
- a
CompletionStageof typePublisherwhich represents all elements of thisPublisherupon successful termination.
-
toInputStream
public final java.io.InputStream toInputStream(java.util.function.Function<? super T,byte[]> serializer)
Subscribes tothisPublisherand converts all signals received by thePublisherSource.Subscriberto the returnedInputStreamfollowing the below rules:PublisherSource.Subscriptionreceived byPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is used to request more data when required. If the returnedInputStreamis closed,PublisherSource.Subscriptionis cancelled and any unread data is disposed.- Any items received by
PublisherSource.Subscriber.onNext(Object)are converted to abyte[]using the passedserializer. Thesebytes are available to be read from theInputStream - Any
Throwablereceived byPublisherSource.Subscriber.onError(Throwable)is thrown (wrapped in anIOException) when data is read from the returnedInputStream. This error will be thrown only after draining all queued data, if any. - When
PublisherSource.Subscriber.onComplete()is called, returnedInputStream's read methods will return-1to indicate end of stream after emitting all received data.
Flow control
This operator may pre-fetch may pre-fetch items fromthisPublisherif available to reduce blocking for read operations from the returnedInputStream. In order to increase responsiveness of theInputStreamsome amount of buffering may be done. UsetoInputStream(Function, int)to manage capacity of this buffer.- Parameters:
serializer-Functionthat is invoked for every item emitted bythisPublisher.- Returns:
InputStreamthat emits all data emitted bythisPublisher. IfthisPublisherterminates with an error, same error is thrown (wrapped in anIOException) from the returnedInputStreams read methods after emitting all received data.
-
toInputStream
public final java.io.InputStream toInputStream(java.util.function.Function<? super T,byte[]> serializer, int queueCapacity)
Subscribes tothisPublisherand converts all signals received by thePublisherSource.Subscriberto the returnedInputStreamfollowing the below rules:PublisherSource.Subscriptionreceived byPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is used to request more data when required. If the returnedInputStreamis closed,PublisherSource.Subscriptionis cancelled and any unread data is disposed.- Any items received by
PublisherSource.Subscriber.onNext(Object)are convertedto abyte[]using the passedserializer. Thesebytes are available to be read from theInputStream - Any
Throwablereceived byPublisherSource.Subscriber.onError(Throwable)is thrown (wrapped in anIOException) when data is read from the returnedInputStream. This error will be thrown only after draining all queued data, if any. - When
PublisherSource.Subscriber.onComplete()is called, returnedInputStream's read methods will return-1to indicate end of stream after emitting all received data.
Flow control
This operator may pre-fetch items fromthisPublisherif available to reduce blocking for read operations from the returnedInputStream. In order to increase responsiveness of theInputStreamsome amount of buffering may be done.queueCapacitycan be used to bound this buffer.- Parameters:
serializer-Functionthat is invoked for every item emitted bythisPublisher.queueCapacity- Hint for the capacity of the intermediary queue that stores items that are emitted bythisPublisherbut has not yet been read from the returnedInputStream.- Returns:
InputStreamthat emits all data emitted bythisPublisher. IfthisPublisherterminates with an error, same error is thrown (wrapped in anIOException) from the returnedInputStreams read methods after emitting all received data.
-
toIterable
public final BlockingIterable<T> toIterable()
ConvertsthisPublisherto anBlockingIterable. Every timeBlockingIterable.iterator()is called on the returnedBlockingIterable,thisPublisheris subscribed following the below rules:PublisherSource.Subscriptionreceived byPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is used to request more data when required.- Any items received by
PublisherSource.Subscriber.onNext(Object)is returned from a call toBlockingIterator.next(). - Any
Throwablereceived byPublisherSource.Subscriber.onError(Throwable)is thrown (wrapped in aRuntimeExceptionif required) whenBlockingIterator.next()is called. This error will be thrown only after draining all queued data, if any. - When
PublisherSource.Subscriber.onComplete()is called, returnedBlockingIteratorsIterator.hasNext()will returnfalseBlockingIterator.next()will throwNoSuchElementException. This error will be thrown only after draining all queued data, if any.
Flow control
This operator may pre-fetch items fromthisPublisherif available to reduce blocking ofIterator.hasNext()from the returnedBlockingIterable. In order to increase responsiveness of theIteratorsome amount of buffering may be done. UsetoIterable(int)to manage capacity of this buffer.Blocking
The returnedBlockingIteratorfrom the returnedBlockingIterablewill block onIterator.hasNext()andBlockingIterator.next()if no data is available. This operator may try to reduce this blocking by requesting data ahead of time.- Returns:
BlockingIterablerepresentingthisPublisher. Every timeBlockingIterable.iterator()is invoked on theBlockingIterable,thisPublisheris subscribed.BlockingIterators returned from thisBlockingIterabledo not supportIterator.remove().
-
toIterable
public final BlockingIterable<T> toIterable(int queueCapacityHint)
ConvertsthisPublisherto anBlockingIterable. Every timeBlockingIterable.iterator()is called on the returnedBlockingIterable,thisPublisheris subscribed following the below rules:PublisherSource.Subscriptionreceived byPublisherSource.Subscriber.onSubscribe(PublisherSource.Subscription)is used to request more data when required.- Any items received by
PublisherSource.Subscriber.onNext(Object)is returned from a call toBlockingIterator.next(). - Any
Throwablereceived byPublisherSource.Subscriber.onError(Throwable)is thrown (wrapped in aRuntimeExceptionif required) whenBlockingIterator.next(). This error will be thrown only after draining all queued data, if any. - When
PublisherSource.Subscriber.onComplete()is called, returnedBlockingIteratorsIterator.hasNext()will returnfalseandBlockingIterator.next()will throwNoSuchElementException. This error will be thrown only after draining all queued data, if any.
Flow control
This operator may pre-fetch items fromthisPublisherif available to reduce blocking ofIterator.hasNext()from the returnedBlockingIterable. In order to increase responsiveness of theBlockingIteratorsome amount of buffering may be done.queueCapacityHintcan be used to bound this buffer.Blocking
The returnedBlockingIteratorfrom the returnedBlockingIterablewill block onIterator.hasNext()andBlockingIterator.next()if no data is available. This operator may try to reduce this blocking by requesting data ahead of time.- Parameters:
queueCapacityHint- Hint for the capacity of the intermediary queue that stores items that are emitted bythisPublisherbut has not yet been returned from theBlockingIterator.- Returns:
BlockingIterablerepresentingthisPublisher. Every timeBlockingIterable.iterator()is invoked on theBlockingIterable,thisPublisheris subscribed.BlockingIterators returned from thisBlockingIterabledo not supportIterator.remove().
-
subscribeInternal
protected final void subscribeInternal(PublisherSource.Subscriber<? super T> subscriber)
A internal subscribe method similar toPublisherSource.subscribe(Subscriber)which can be used by different implementations to subscribe.- Parameters:
subscriber-PublisherSource.Subscriberto subscribe for the result.
-
handleSubscribe
protected abstract void handleSubscribe(PublisherSource.Subscriber<? super T> subscriber)
Handles a subscriber to thisPublisher.- Parameters:
subscriber- the subscriber.
-
from
public static <T> Publisher<T> from(@Nullable T value)
Creates a newPublisherthat emitsvalueto itsPublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().- Type Parameters:
T- Type of items emitted by the returnedPublisher.- Parameters:
value- Value that the returnedPublisherwill emit.- Returns:
- A new
Publisherthat emitsvalueto itsPublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete(). - See Also:
- ReactiveX just operator.
-
from
public static <T> Publisher<T> from(@Nullable T v1, @Nullable T v2)
Creates a newPublisherthat emitsv1andv2to itsPublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().- Type Parameters:
T- Type of items emitted by the returnedPublisher.- Parameters:
v1- The first value that the returnedPublisherwill emit.v2- The second value that the returnedPublisherwill emit.- Returns:
- A new
Publisherthat emitsv1andv2to itsPublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete(). - See Also:
- ReactiveX just operator.
-
from
public static <T> Publisher<T> from(@Nullable T v1, @Nullable T v2, @Nullable T v3)
Creates a newPublisherthat emitsv1,v2, andv3to itsPublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().- Type Parameters:
T- Type of items emitted by the returnedPublisher.- Parameters:
v1- The first value that the returnedPublisherwill emit.v2- The second value that the returnedPublisherwill emit.v3- The third value that the returnedPublisherwill emit.- Returns:
- A new
Publisherthat emitsv1,v2, andv3to itsPublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete(). - See Also:
- ReactiveX just operator.
-
from
@SafeVarargs public static <T> Publisher<T> from(T... values)
Creates a newPublisherthat emits allvaluesto itsPublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().- Type Parameters:
T- Type of items emitted by the returnedPublisher.- Parameters:
values- Values that the returnedPublisherwill emit.- Returns:
- A new
Publisherthat emits allvaluesto itsPublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete(). - See Also:
- ReactiveX from operator.
-
fromIterable
public static <T> Publisher<T> fromIterable(java.lang.Iterable<? extends T> iterable)
Create a newPublisherthat when subscribed will get anIteratorviaIterable.iterator()and emit all values to thePublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().The Reactive Streams specification provides two criteria ( 3.4, and 3.5) stating the
PublisherSource.Subscriptionshould be "responsive". The responsiveness of the associatedPublisherSource.Subscriptions will depend upon the behavior of theiterablebelow. Make sure theExecutorfor this execution chain can tolerate this responsiveness and any blocking behavior.- Type Parameters:
T- Type of items emitted by the returnedPublisher.- Parameters:
iterable- used to obtain instances ofIteratorto extract data from.Iterable.iterator()must not returnnull. If this is of typeBlockingIterablethen any generatedBlockingIterators will have theirBlockingIterator.close()method called if an error occurs.- Returns:
- a new
Publisherthat when subscribed will get anIteratorviaIterable.iterator()and emit all values to thePublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().
-
fromBlockingIterable
public static <T> Publisher<T> fromBlockingIterable(BlockingIterable<? extends T> iterable, java.util.function.LongSupplier timeoutSupplier, java.util.concurrent.TimeUnit unit)
Create a newPublisherthat when subscribed will get aBlockingIteratorviaBlockingIterable.iterator()and emit all values to thePublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().The Reactive Streams specification provides two criteria ( 3.4, and 3.5) stating the
PublisherSource.Subscriptionshould be "responsive". The responsiveness of the associatedPublisherSource.Subscriptions will depend upon the behavior of theiterablebelow. Make sure theExecutorfor this execution chain can tolerate this responsiveness and any blocking behavior.- Type Parameters:
T- Type of items emitted by the returnedPublisher.- Parameters:
iterable- used to obtain instances ofIteratorto extract data from.Iterable.iterator()must not returnnull. Any generatedBlockingIterators will have theirBlockingIterator.close()method called if an error occurs.timeoutSupplier- ALongSupplierwhich provides the time duration to wait for each interaction withiterable.unit- The time units for thetimeoutduration.- Returns:
- a new
Publisherthat when subscribed will get aBlockingIteratorviaBlockingIterable.iterator()and emit all values to thePublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().
-
fromInputStream
public static Publisher<byte[]> fromInputStream(java.io.InputStream stream)
Create a newPublisherthat when subscribed will emit all data from theInputStreamto thePublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().The Reactive Streams specification provides two criteria ( 3.4, and 3.5) stating the
PublisherSource.Subscriptionshould be "responsive". The responsiveness of the associatedPublisherSource.Subscriptions will depend upon the behavior of thestreambelow. Make sure theExecutorfor this execution chain can tolerate this responsiveness and any blocking behavior.- Parameters:
stream- provides the data in the form ofbyte[]to be emitted to thePublisherSource.Subscriberby the returnedPublisher. Given the blocking nature ofInputStream, assumePublisherSource.Subscription.request(long)can block when the underlyingInputStreamblocks onInputStream.read(byte[], int, int).- Returns:
- a new
Publisherthat when subscribed will emit all data from theInputStreamto thePublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().
-
fromInputStream
public static Publisher<byte[]> fromInputStream(java.io.InputStream stream, int readChunkSize)
Create a newPublisherthat when subscribed will emit all data from theInputStreamto thePublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().The Reactive Streams specification provides two criteria ( 3.4, and 3.5) stating the
PublisherSource.Subscriptionshould be "responsive". The responsiveness of the associatedPublisherSource.Subscriptions will depend upon the behavior of thestreambelow. Make sure theExecutorfor this execution chain can tolerate this responsiveness and any blocking behavior.- Parameters:
stream- provides the data in the form ofbyte[]to be emitted to thePublisherSource.Subscriberby the returnedPublisher. Given the blocking nature ofInputStream, assumePublisherSource.Subscription.request(long)can block when the underlyingInputStreamblocks onInputStream.read(byte[], int, int).readChunkSize- the maximum length ofbyte[]chunks which will be read from theInputStreamand emitted by the returnedPublisher.- Returns:
- a new
Publisherthat when subscribed will emit all data from theInputStreamto thePublisherSource.Subscriberand thenPublisherSource.Subscriber.onComplete().
-
range
public static Publisher<java.lang.Integer> range(int begin, int end)
Create a newPublisherthat when subscribed will emit allIntegers within the range of [begin,end).
-
range
public static Publisher<java.lang.Integer> range(int begin, int end, int stride)
Create a newPublisherthat when subscribed will emit allIntegers within the range of [begin,end) with an increment ofstridebetween each signal.- Parameters:
begin- The beginning of the range (inclusive).end- The end of the range (exclusive).stride- The amount to increment in between each signal.- Returns:
- a new
Publisherthat when subscribed will emit allIntegers within the range of [begin,end) with an increment ofstridebetween each signal. - See Also:
- Range.
-
empty
public static <T> Publisher<T> empty()
Creates a newPublisherthat completes when subscribed without emitting any item to itsPublisherSource.Subscriber.- Type Parameters:
T- Type of items emitted by the returnedPublisher.- Returns:
- A new
Publisherthat completes when subscribed without emitting any item to itsPublisherSource.Subscriber. - See Also:
- ReactiveX empty operator.
-
never
public static <T> Publisher<T> never()
Creates a newPublisherthat never emits any item to itsPublisherSource.Subscriberand never call any terminal methods on it.- Type Parameters:
T- Type of items emitted by the returnedPublisher.- Returns:
- A new
Publisherthat never emits any item to itsPublisherSource.Subscriberand never call any terminal methods on it. - See Also:
- ReactiveX never operator.
-
failed
public static <T> Publisher<T> failed(java.lang.Throwable cause)
Creates a newPublisherthat terminates itsPublisherSource.Subscriberwith an error without emitting any item to it.- Type Parameters:
T- Type of items emitted by the returnedPublisher.- Parameters:
cause- TheThrowablethat is used to terminate thePublisherSource.Subscriber.- Returns:
- A new
Publisherthat terminates itsPublisherSource.Subscriberwith an error without emitting any item to it. - See Also:
- ReactiveX error operator.
-
defer
public static <T> Publisher<T> defer(java.util.function.Supplier<? extends Publisher<? extends T>> publisherSupplier)
Defers creation of aPublishertill it is subscribed.- Type Parameters:
T- Type of items emitted by the returnedPublisher.- Parameters:
publisherSupplier-Supplierto create a newPublisherevery time the returnedPublisheris subscribed.- Returns:
- A new
Publisherthat creates a newPublisherusingpublisherSupplierevery time it is subscribed and forwards all items and terminal events from the newly createdPublisherto itsPublisherSource.Subscriber. - See Also:
- ReactiveX defer operator.
-
-