@Test public void testReplaySelector() { final Function<Integer, Integer> dbl = new Function<Integer, Integer>() { @Override public Integer apply(Integer t1) { return t1 * 2; } }; Function<Flowable<Integer>, Flowable<Integer>> selector = new Function<Flowable<Integer>, Flowable<Integer>>() { @Override public Flowable<Integer> apply(Flowable<Integer> t1) { return t1.map(dbl); } }; PublishProcessor<Integer> source = PublishProcessor.create(); Flowable<Integer> co = source.replay(selector); { Subscriber<Object> observer1 = TestHelper.mockSubscriber(); InOrder inOrder = inOrder(observer1); co.subscribe(observer1); source.onNext(1); source.onNext(2); source.onNext(3); inOrder.verify(observer1, times(1)).onNext(2); inOrder.verify(observer1, times(1)).onNext(4); inOrder.verify(observer1, times(1)).onNext(6); source.onNext(4); source.onComplete(); inOrder.verify(observer1, times(1)).onNext(8); inOrder.verify(observer1, times(1)).onComplete(); inOrder.verifyNoMoreInteractions(); verify(observer1, never()).onError(any(Throwable.class)); } { Subscriber<Object> observer1 = TestHelper.mockSubscriber(); InOrder inOrder = inOrder(observer1); co.subscribe(observer1); inOrder.verify(observer1, times(1)).onComplete(); inOrder.verifyNoMoreInteractions(); verify(observer1, never()).onError(any(Throwable.class)); } }
public static <T> ConnectableFlowable<T> create(Flowable<T> source, final int bufferSize) { if (bufferSize == Integer.MAX_VALUE) { return createFrom(source); } return create(source, new ReplayBufferTask<T>(bufferSize)); }
FlowableReplay extends ConnectableFlowable<T> implements HasUpstreamPublisher<T>, Disposable { public static <T> ConnectableFlowable<T> create(Flowable<T> source, final int bufferSize) { if (bufferSize == Integer.MAX_VALUE) { return createFrom(source); } return create(source, new ReplayBufferTask<T>(bufferSize)); } }
FlowableReplay extends ConnectableFlowable<T> implements HasUpstreamPublisher<T>, Disposable { public static <T> ConnectableFlowable<T> create(Flowable<T> source, final int bufferSize) { if (bufferSize == Integer.MAX_VALUE) { return createFrom(source); } return create(source, new ReplayBufferTask<T>(bufferSize)); } private  FlowableReplay(Publisher<T> onSubscribe, Flowable<T> source,
            final AtomicReference<ReplaySubscriber<T>> current,
            final Callable<? extends ReplayBuffer<T>> bufferFactory); }
FlowableReplay extends ConnectableFlowable<T> implements HasUpstreamPublisher<T>, Disposable { public static <T> ConnectableFlowable<T> create(Flowable<T> source, final int bufferSize) { if (bufferSize == Integer.MAX_VALUE) { return createFrom(source); } return create(source, new ReplayBufferTask<T>(bufferSize)); } private  FlowableReplay(Publisher<T> onSubscribe, Flowable<T> source,
            final AtomicReference<ReplaySubscriber<T>> current,
            final Callable<? extends ReplayBuffer<T>> bufferFactory); static Flowable<R> multicastSelector(
            final Callable<? extends ConnectableFlowable<U>> connectableFactory,
            final Function<? super Flowable<U>, ? extends Publisher<R>> selector); static ConnectableFlowable<T> observeOn(final ConnectableFlowable<T> cf, final Scheduler scheduler); @SuppressWarnings("unchecked") static ConnectableFlowable<T> createFrom(Flowable<? extends T> source); static ConnectableFlowable<T> create(Flowable<T> source,
            final int bufferSize); static ConnectableFlowable<T> create(Flowable<T> source,
            long maxAge, TimeUnit unit, Scheduler scheduler); static ConnectableFlowable<T> create(Flowable<T> source,
            final long maxAge, final TimeUnit unit, final Scheduler scheduler, final int bufferSize); @Override Publisher<T> source(); @Override void dispose(); @Override boolean isDisposed(); @Override void connect(Consumer<? super Disposable> connection); }
FlowableReplay extends ConnectableFlowable<T> implements HasUpstreamPublisher<T>, Disposable { public static <T> ConnectableFlowable<T> create(Flowable<T> source, final int bufferSize) { if (bufferSize == Integer.MAX_VALUE) { return createFrom(source); } return create(source, new ReplayBufferTask<T>(bufferSize)); } private  FlowableReplay(Publisher<T> onSubscribe, Flowable<T> source,
            final AtomicReference<ReplaySubscriber<T>> current,
            final Callable<? extends ReplayBuffer<T>> bufferFactory); static Flowable<R> multicastSelector(
            final Callable<? extends ConnectableFlowable<U>> connectableFactory,
            final Function<? super Flowable<U>, ? extends Publisher<R>> selector); static ConnectableFlowable<T> observeOn(final ConnectableFlowable<T> cf, final Scheduler scheduler); @SuppressWarnings("unchecked") static ConnectableFlowable<T> createFrom(Flowable<? extends T> source); static ConnectableFlowable<T> create(Flowable<T> source,
            final int bufferSize); static ConnectableFlowable<T> create(Flowable<T> source,
            long maxAge, TimeUnit unit, Scheduler scheduler); static ConnectableFlowable<T> create(Flowable<T> source,
            final long maxAge, final TimeUnit unit, final Scheduler scheduler, final int bufferSize); @Override Publisher<T> source(); @Override void dispose(); @Override boolean isDisposed(); @Override void connect(Consumer<? super Disposable> connection);  }