T
- Subscriber typepublic class AsyncSubscriber<T> extends java.lang.Object implements org.reactivestreams.Subscriber<T>, PushSubscriber<T>
Spouts.reactiveSubscriber()
PushSubscriber<Integer> sub = Spouts.asyncSubscriber();
//on a seperate thread
for(int i=0;i<100;i++)
sub.onNext(i);
sub.onComplete();
//on the main thread
sub.stream()
.peek(System.out::println)
.collect(CyclopsCollectors.toList());
//note JDK Stream based terminal operations may block the current thread
//see ReactiveSeq#collectStream ReactiveSeq#foldAll for non-blocking alternatives
Constructor and Description |
---|
AsyncSubscriber() |
Modifier and Type | Method and Description |
---|---|
void |
awaitInitialization() |
boolean |
isInitialized() |
void |
onComplete() |
void |
onError(java.lang.Throwable t) |
void |
onNext(T t) |
void |
onSubscribe(org.reactivestreams.Subscription s) |
ReactiveSeq<T> |
registerAndstream(java.lang.Runnable r) |
ReactiveSeq<T> |
stream()
PushSubscriber<Integer> sub = Spouts.asyncSubscriber();
//on a seperate thread
for(int i=0;i<100;i++)
sub.onNext(i);
sub.onComplete();
//on the main thread
sub.stream()
.peek(System.out::println)
.collect(CyclopsCollectors.toList());
//note JDK Stream based terminal operations may block the current thread
//see ReactiveSeq#collectStream ReactiveSeq#foldAll for non-blocking alternatives
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
asSubscriber, of
public ReactiveSeq<T> stream()
PushSubscriber<Integer> sub = Spouts.asyncSubscriber();
//on a seperate thread
for(int i=0;i<100;i++)
sub.onNext(i);
sub.onComplete();
//on the main thread
sub.stream()
.peek(System.out::println)
.collect(CyclopsCollectors.toList());
//note JDK Stream based terminal operations may block the current thread
//see ReactiveSeq#collectStream ReactiveSeq#foldAll for non-blocking alternatives
public ReactiveSeq<T> registerAndstream(java.lang.Runnable r)
public void onSubscribe(org.reactivestreams.Subscription s)
onSubscribe
in interface org.reactivestreams.Subscriber<T>
public void onNext(T t)
onNext
in interface PushSubscriber<T>
onNext
in interface org.reactivestreams.Subscriber<T>
public void onError(java.lang.Throwable t)
onError
in interface PushSubscriber<T>
onError
in interface org.reactivestreams.Subscriber<T>
public void onComplete()
onComplete
in interface PushSubscriber<T>
onComplete
in interface org.reactivestreams.Subscriber<T>
public boolean isInitialized()
isInitialized
in interface PushSubscriber<T>
public void awaitInitialization()