public static <I, O> Observable.Transformer<I, O> toTransformer( final Connectable<I, O> connectable) { return toTransformer(connectable, BackpressureMode.NONE); } }
/** * Create a {@link MobiusLoop.Builder} to help you configure a MobiusLoop before starting it. * * <p>Once done configuring the loop you can start the loop using {@link * MobiusLoop.Factory#startFrom(Object)}. * * @param update the {@link Update} function of the loop * @param effectHandler the {@link Transformer} effect handler of the loop * @param <M> the model type * @param <E> the event type * @param <F> the effect type * @return a {@link MobiusLoop.Builder} instance that you can further configure before starting * the loop */ public static <M, E, F> MobiusLoop.Builder<M, E, F> loop( Update<M, E, F> update, Transformer<F, E> effectHandler) { return Mobius.loop(update, RxConnectables.fromTransformer(effectHandler)); }
@Test public void shouldPropagateErrorsFromUpstream() throws Exception { final Throwable expected = new RuntimeException("expected"); AssertableSubscriber<Integer> subscriber = input.compose(RxConnectables.toTransformer(connectable)).test(); input.onError(expected); subscriber.awaitTerminalEvent(1, TimeUnit.SECONDS); subscriber.assertError(expected); } }
@Test public void shouldPropagateErrorsFromConnectable() throws Exception { AssertableSubscriber<Integer> subscriber = input.compose(RxConnectables.toTransformer(connectable)).test(); input.onNext("crash"); subscriber.awaitTerminalEvent(1, TimeUnit.SECONDS); subscriber.assertFailureAndMessage(RuntimeException.class, "crashing!"); }
@Test public void shouldPropagateCompletion() throws Exception { AssertableSubscriber<Integer> subscriber = input.compose(RxConnectables.toTransformer(connectable)).test(); input.onNext("hi"); input.onCompleted(); subscriber.awaitTerminalEvent(1, TimeUnit.SECONDS); subscriber.assertCompleted(); }