@Override public void onNext(final T t) { Objects.requireNonNull(t); if(subscription==null){ buffer.add(t); return; } val cons = getAction().getAction(); if(cons!=null) cons.accept(t); }
@Override public void onError(final Throwable t) { Objects.requireNonNull(t); if(subscription==null) error= t; val cons = getAction().getError(); if(cons!=null) cons.accept(t); }
public boolean isInitialized() { return getAction().isInitialized(); }
/** * <pre> * {@code * ReactiveSubscriber<Integer> sub = Spouts.reactiveSubscriber(); Flux.just(1,2,3).forEachAsync(sub); sub.stream().forEach(System.out::println); * //note JDK Stream based terminal operations may block the current thread * //see ReactiveSeq#collectStream ReactiveSeq#foldAll for non-blocking alternatives * } * </pre> * * @return A push-based asychronous event driven Observable-style Stream that implements Backpressure via the reactive-streams API */ public ReactiveSeq<T> reactiveStream(){ streamCreated = true; ReactiveSeq<T> result = Spouts.reactiveStream(getAction()); if(complete) return ReactiveSeq.fromIterable(buffer); if(error!=null) throw ExceptionSoftener.throwSoftenedException(error); if(buffer.size()>0){ return Spouts.concat(Spouts.fromIterable(buffer),result); } return result; }
@Override public void onError(final Throwable t) { Objects.requireNonNull(t); if(subscription==null) error= t; val cons = getAction().getError(); if(cons!=null) cons.accept(t); }
@Override public void onNext(final T t) { Objects.requireNonNull(t); if(subscription==null){ buffer.add(t); return; } val cons = getAction().getAction(); if(cons!=null) cons.accept(t); }
public boolean isInitialized() { return getAction().isInitialized(); }
/** * <pre> * {@code * ReactiveSubscriber<Integer> sub = Spouts.reactiveSubscriber(); Flux.just(1,2,3).forEachAsync(sub); sub.stream().forEach(System.out::println); * //note JDK Stream based terminal operations may block the current thread * //see ReactiveSeq#collectStream ReactiveSeq#foldAll for non-blocking alternatives * } * </pre> * * @return A push-based asychronous event driven Observable-style Stream that implements Backpressure via the reactive-streams API */ public ReactiveSeq<T> reactiveStream(){ streamCreated = true; ReactiveSeq<T> result = Spouts.reactiveStream(getAction()); if(complete) return ReactiveSeq.fromIterable(buffer); if(error!=null) throw ExceptionSoftener.throwSoftenedException(error); if(buffer.size()>0){ return Spouts.concat(Spouts.fromIterable(buffer),result); } return result; }