MobiusLoopViewModel extends ViewModel { @Nonnull public final LiveQueue<V> getViewEffects() { return viewEffectQueue; } protected  MobiusLoopViewModel(
      @Nonnull Function<Consumer<V>, MobiusLoop.Factory<M, E, F>> loopFactoryProvider,
      @Nonnull M modelToStartFrom,
      @Nonnull Init<M, F> init,
      @Nonnull WorkRunner mainLoopWorkRunner,
      int maxEffectQueueSize); static MobiusLoopViewModel<M, E, F, V> create(
      @Nonnull Function<Consumer<V>, MobiusLoop.Factory<M, E, F>> loopFactoryProvider,
      @Nonnull M modelToStartFrom,
      @Nonnull Init<M, F> init); static MobiusLoopViewModel<M, E, F, V> create(
      @Nonnull Function<Consumer<V>, MobiusLoop.Factory<M, E, F>> loopFactoryProvider,
      @Nonnull M modelToStartFrom,
      @Nonnull Init<M, F> init,
      int maxEffectsToQueue); @Nonnull final M getModel(); @Nonnull final LiveData<M> getModels(); @Nonnull final LiveQueue<V> getViewEffects(); final void dispatchEvent(@Nonnull E event);  }
@Test public void testViewEffectsPostedImmediatelyAreSentCorrectly() { underTest = new MobiusLoopViewModel<>( (Consumer<TestViewEffect> consumer) -> { Connectable<TestEffect, TestEvent> viewEffectSendingEffectHandler = new ViewEffectSendingEffectHandler(consumer); testViewEffectHandler = new TestViewEffectHandler<>(consumer); return Mobius.loop(updateFunction, viewEffectSendingEffectHandler) .eventRunner(ImmediateWorkRunner::new) .effectRunner(ImmediateWorkRunner::new); }, initialModel, (TestModel model) -> First.first(model, effects(new TestEffect("oops"))), new ImmediateWorkRunner(), 100); underTest .getViewEffects() .setObserver( fakeLifecycle, recordingForegroundViewEffectObserver, recordingBackgroundEffectObserver); fakeLifecycle.handleLifecycleEvent(Lifecycle.Event.ON_RESUME); assertThat(recordingForegroundViewEffectObserver.valueCount(), equalTo(0)); assertThat(recordingBackgroundEffectObserver.valueCount(), equalTo(1)); }