Package com.spotify.mobius.rx
Class RxMobius
- java.lang.Object
-
- com.spotify.mobius.rx.RxMobius
-
public final class RxMobius extends java.lang.ObjectFactory methods for wrapping Mobius core classes in observable transformers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRxMobius.SubtypeEffectHandlerBuilder<F,E>Builder for a type-routing effect handler.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <M,E,F>
com.spotify.mobius.MobiusLoop.Builder<M,E,F>loop(com.spotify.mobius.Update<M,E,F> update, rx.Observable.Transformer<F,E> effectHandler)Create aMobiusLoop.Builderto help you configure a MobiusLoop before starting it.static <M,E,F>
rx.Observable.Transformer<E,M>loopFrom(com.spotify.mobius.MobiusLoop.Factory<M,E,F> loopFactory, M startModel)Create an observable transformer that starts from a given model.static <M,E,F>
rx.Observable.Transformer<E,M>loopFrom(com.spotify.mobius.MobiusLoop.Factory<M,E,F> loopFactory, M startModel, java.util.Set<F> startEffects)Create an observable transformer that starts from a given model and given effects.static <F,E>
RxMobius.SubtypeEffectHandlerBuilder<F,E>subtypeEffectHandler()Create anRxMobius.SubtypeEffectHandlerBuilderfor handling effects based on their type.
-
-
-
Method Detail
-
loopFrom
public static <M,E,F> rx.Observable.Transformer<E,M> loopFrom(com.spotify.mobius.MobiusLoop.Factory<M,E,F> loopFactory, M startModel)Create an observable transformer that starts from a given model.Every time the resulting observable is subscribed to, a new MobiusLoop will be started from the given model.
- Type Parameters:
M- the model typeE- the event typeF- the effect type- Parameters:
loopFactory- gets invoked for each subscription, to create a new MobiusLoop instancestartModel- the starting point for each new loop- Returns:
- a transformer from event to model that you can connect to your UI
-
loopFrom
public static <M,E,F> rx.Observable.Transformer<E,M> loopFrom(com.spotify.mobius.MobiusLoop.Factory<M,E,F> loopFactory, M startModel, java.util.Set<F> startEffects)Create an observable transformer that starts from a given model and given effects.Every time the resulting observable is subscribed to, a new MobiusLoop will be started from the given model and the given effects.
- Type Parameters:
M- the model typeE- the event typeF- the effect type- Parameters:
loopFactory- gets invoked for each subscription, to create a new MobiusLoop instancestartModel- the starting point for each new loopstartEffects- the starting effects for each new loop- Returns:
- a transformer from event to model that you can connect to your UI
-
loop
public static <M,E,F> com.spotify.mobius.MobiusLoop.Builder<M,E,F> loop(com.spotify.mobius.Update<M,E,F> update, rx.Observable.Transformer<F,E> effectHandler)Create aMobiusLoop.Builderto help you configure a MobiusLoop before starting it.Once done configuring the loop you can start the loop using
MobiusLoop.Factory.startFrom(Object).- Type Parameters:
M- the model typeE- the event typeF- the effect type- Parameters:
update- theUpdatefunction of the loopeffectHandler- theObservable.Transformereffect handler of the loop- Returns:
- a
MobiusLoop.Builderinstance that you can further configure before starting the loop
-
subtypeEffectHandler
public static <F,E> RxMobius.SubtypeEffectHandlerBuilder<F,E> subtypeEffectHandler()
Create anRxMobius.SubtypeEffectHandlerBuilderfor handling effects based on their type.- Type Parameters:
F- the effect typeE- the event type
-
-