Class AsyncSubscriber<T>
- java.lang.Object
-
- org.reactivestreams.example.unicast.AsyncSubscriber<T>
-
- All Implemented Interfaces:
java.lang.Runnable
,org.reactivestreams.Subscriber<T>
public abstract class AsyncSubscriber<T> extends java.lang.Object implements org.reactivestreams.Subscriber<T>, java.lang.Runnable
AsyncSubscriber is an implementation of Reactive Streams `Subscriber`, it runs asynchronously (on an Executor), requests one element at a time, and invokes a user-defined method to process each element. NOTE: The code below uses a lot of try-catches to show the reader where exceptions can be expected, and where they are forbidden.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AsyncSubscriber(java.util.concurrent.Executor executor)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
onComplete()
void
onError(java.lang.Throwable t)
void
onNext(T element)
void
onSubscribe(org.reactivestreams.Subscription s)
void
run()
protected void
whenComplete()
protected void
whenError(java.lang.Throwable error)
protected abstract boolean
whenNext(T element)
-
-
-
Constructor Detail
-
AsyncSubscriber
protected AsyncSubscriber(java.util.concurrent.Executor executor)
-
-
Method Detail
-
whenComplete
protected void whenComplete()
-
whenError
protected void whenError(java.lang.Throwable error)
-
onSubscribe
public final void onSubscribe(org.reactivestreams.Subscription s)
- Specified by:
onSubscribe
in interfaceorg.reactivestreams.Subscriber<T>
-
onNext
public final void onNext(T element)
- Specified by:
onNext
in interfaceorg.reactivestreams.Subscriber<T>
-
onError
public final void onError(java.lang.Throwable t)
- Specified by:
onError
in interfaceorg.reactivestreams.Subscriber<T>
-
onComplete
public final void onComplete()
- Specified by:
onComplete
in interfaceorg.reactivestreams.Subscriber<T>
-
run
public final void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
-