T
- Subscriber typepublic class AsyncSubscriber<T>
extends java.lang.Object
implements org.reactivestreams.Subscriber<T>
Spouts.reactiveSubscriber()
AsyncSubscriber<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.reactiveStream()
.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()
AsyncSubscriber<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.reactiveStream()
.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> stream()
AsyncSubscriber<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.reactiveStream()
.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 onError(java.lang.Throwable t)
onError
in interface org.reactivestreams.Subscriber<T>
public void onComplete()
onComplete
in interface org.reactivestreams.Subscriber<T>
public boolean isInitialized()
public void awaitInitialization()