T
- Type of the items emitted by this TestPublisher
.public final class TestPublisher<T> extends Publisher<T> implements PublisherSource<T>
Publisher
& PublisherSource
whose outgoing signals to its Subscriber
s can be
controlled.
Behavior beyond simply delegating signals to the Subscriber
is accomplished by a
Function<Subscriber<? super T>, Subscriber<? super T>>
. This Function
is
invoked for every PublisherSource.subscribe(Subscriber)
invocation, and the result is used as the delegate for subsequent
#onSubscribe(Subscription)
, onNext(Object[])
, onComplete()
, and
onError(Throwable)
calls. See TestPublisher.Builder
for more information.
onNext(Object[])
is not called without sufficient demand.#onSubscribe(Subscription)
automatically when subscribed to.Modifier and Type | Class and Description |
---|---|
static class |
TestPublisher.Builder<T>
Allows for creating
TestPublisher s with non-default settings. |
PublisherSource.Processor<T,R>, PublisherSource.Subscriber<T>, PublisherSource.Subscription
Constructor and Description |
---|
TestPublisher()
Create a
TestPublisher with the defaults. |
Modifier and Type | Method and Description |
---|---|
protected void |
handleSubscribe(PublisherSource.Subscriber<? super T> subscriber)
Handles a subscriber to this
Publisher . |
boolean |
isSubscribed()
|
void |
onComplete()
Completes the
Subscriber . |
void |
onError(java.lang.Throwable t)
Delivers the
Throwable t to the Subscriber . |
void |
onNext(T... items)
Delivers the
items , one at a time, to the Subscriber . |
void |
onSubscribe(PublisherSource.Subscription subscription)
Delivers the
Subscription to the Subscriber 's Subscriber#onSubscribe(Subscription) . |
void |
subscribe(PublisherSource.Subscriber<? super T> subscriber)
Subscribe for the result(s) of this
PublisherSource . |
afterCancel, afterFinally, afterFinally, afterOnComplete, afterOnError, afterOnNext, afterOnSubscribe, afterRequest, afterSubscriber, afterSubscription, beforeCancel, beforeFinally, beforeFinally, beforeOnComplete, beforeOnError, beforeOnNext, beforeOnSubscribe, beforeRequest, beforeSubscriber, beforeSubscription, buffer, collect, concat, concat, concat, defer, empty, failed, filter, firstOrElse, firstOrError, flatMapCompletable, flatMapCompletable, flatMapCompletableDelayError, flatMapCompletableDelayError, flatMapConcatIterable, flatMapMerge, flatMapMerge, flatMapMergeDelayError, flatMapMergeDelayError, flatMapMergeSingle, flatMapMergeSingle, flatMapMergeSingleDelayError, flatMapMergeSingleDelayError, forEach, from, from, fromBlockingIterable, fromInputStream, fromIterable, groupBy, groupBy, groupToMany, groupToMany, idleTimeout, idleTimeout, idleTimeout, idleTimeout, ignoreElements, liftAsync, liftSync, liftSyncToSingle, map, multicastToExactly, multicastToExactly, never, publishAndSubscribeOn, publishAndSubscribeOnOverride, publishOn, publishOnOverride, range, range, recoverWith, repeat, repeatWhen, retry, retryWhen, subscribeInternal, subscribeOn, subscribeOnOverride, subscribeShareContext, takeAtMost, takeUntil, takeWhile, toCompletionStage, toCompletionStage, toFuture, toFuture, toInputStream, toInputStream, toIterable, toIterable, whenCancel, whenFinally, whenFinally, whenOnComplete, whenOnError, whenOnNext, whenOnSubscribe, whenRequest, whenSubscriber, whenSubscription
public TestPublisher()
TestPublisher
with the defaults. See Defaults section of class javadoc.public boolean isSubscribed()
true
if this TestPublisher
has been subscribed to, false
otherwise.protected void handleSubscribe(PublisherSource.Subscriber<? super T> subscriber)
Publisher
Publisher
.handleSubscribe
in class Publisher<T>
subscriber
- the subscriber.public void subscribe(PublisherSource.Subscriber<? super T> subscriber)
PublisherSource
PublisherSource
.subscribe
in interface PublisherSource<T>
subscriber
- to subscribe for the result.public void onSubscribe(PublisherSource.Subscription subscription)
Subscription
to the Subscriber
's Subscriber#onSubscribe(Subscription)
.
In the case of auto-on-subscribe
, the delegating Subscription
sent to
the Subscriber
by the auto-on-subscribe will switch to subscription
.
subscription
- the Subscription
@SafeVarargs public final void onNext(@Nullable T... items)
items
, one at a time, to the Subscriber
.items
- the items to deliver.Subscriber#onNext(Object)
public void onComplete()
Subscriber
.Subscriber#onComplete()
public void onError(java.lang.Throwable t)
Throwable
t
to the Subscriber
.t
- the error to deliver.Subscriber#onError(Throwable)