Skip to content

ReactiveStreams : SeqSubscriber

johnmcclean-aol edited this page Nov 23, 2016 · 1 revision

SeqSubscriber

SeqSubscriber is a ReactiveStreams subscriber that will subscribe to a ReactiveStreams Publisher and extract sequences e.g.

SeqSubscriber<Integer> ints = SeqSubscriber.subscriber();
ReactiveSeq.of(1,2,3)
           .publish(ints);
ListX<Integer> list = ints.toListX();

ReactiveSeq<Integer> seq = ints.toStream();

Errors and events are propagated from upstream pipelines to downstream ones e.g.

SeqSubscriber<Integer> sub = SeqSubscriber.subscriber();
ReactiveSeq.of(1,2,3)
           .peek(i->{throw new RuntimeException("boo!");})
           .subscribe(sub);
        
sub.stream()
    .forEachWithError(System.out::println, System.err::println);
Clone this wiki locally