Class RxMobius


  • public final class RxMobius
    extends java.lang.Object
    Factory methods for wrapping Mobius core classes in observable transformers.
    • 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 a MobiusLoop.Builder to 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 an RxMobius.SubtypeEffectHandlerBuilder for handling effects based on their type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 type
        E - the event type
        F - the effect type
        Parameters:
        loopFactory - gets invoked for each subscription, to create a new MobiusLoop instance
        startModel - 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 type
        E - the event type
        F - the effect type
        Parameters:
        loopFactory - gets invoked for each subscription, to create a new MobiusLoop instance
        startModel - the starting point for each new loop
        startEffects - 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 a MobiusLoop.Builder to 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 type
        E - the event type
        F - the effect type
        Parameters:
        update - the Update function of the loop
        effectHandler - the Observable.Transformer effect handler of the loop
        Returns:
        a MobiusLoop.Builder instance that you can further configure before starting the loop