/** * Add an {@link Action1} for handling effects of a given type. The action will be invoked once * for every received effect object that extends the given class. * * <p>Adding handlers for two effect classes where one is a super-class of the other is * considered a collision and is not allowed. Registering the same class twice is also * considered a collision. * * @param effectClass the class to handle * @param action the action that should be invoked for the effect * @param <G> the effect class as a type parameter * @return this builder * @throws IllegalArgumentException if there is a handler collision * @deprecated use {@link #addConsumer(Class, Action1)} */ @Deprecated public <G extends F> SubtypeEffectHandlerBuilder<F, E> add( final Class<G> effectClass, final Action1<G> action) { return addConsumer(effectClass, action); }
/** * Add an {@link Action1} for handling effects of a given type. The action will be invoked once * for every received effect object that extends the given class. * * <p>Adding handlers for two effect classes where one is a super-class of the other is * considered a collision and is not allowed. Registering the same class twice is also * considered a collision. * * @param effectClass the class to handle * @param action the action that should be invoked for the effect * @param scheduler the scheduler that should be used to invoke the action * @param <G> the effect class as a type parameter * @return this builder * @throws IllegalArgumentException if there is a handler collision * @deprecated use {@link #addConsumer(Class, Action1, Scheduler)} */ @Deprecated public <G extends F> SubtypeEffectHandlerBuilder<F, E> add( final Class<G> effectClass, final Action1<G> action, Scheduler scheduler) { return addConsumer(effectClass, action, scheduler); }
@Before public void setUp() throws Exception { cConsumer = new TestConsumer<>(); dAction = new TestAction(); Transformer<TestEffect, TestEvent> router = RxMobius.<TestEffect, TestEvent>subtypeEffectHandler() .addTransformer(A.class, (Observable<A> as) -> as.map(a -> AEvent.create(a.id()))) .addTransformer(B.class, (Observable<B> bs) -> bs.map(b -> BEvent.create(b.id()))) .addConsumer(C.class, cConsumer) .addAction(D.class, dAction) .addFunction(E.class, e -> AEvent.create(e.id())) .build(); publishSubject = PublishSubject.create(); testSubscriber = TestSubscriber.create(); publishSubject.compose(router).subscribe(testSubscriber); }