-
public class MockMavericksViewModelConfigFactory extends MavericksViewModelConfigFactory
-
-
Field Summary
Fields Modifier and Type Field Description private final Map<MavericksStateStore<?>, MockableMavericksViewModelConfig<?>>currentConfigsprivate MockBehaviormockBehaviorprivate final CoroutineContextcontextOverrideprivate final BooleandebugModeprivate final CoroutineContextstoreContextOverrideprivate final CoroutineContextsubscriptionCoroutineContextOverride
-
Constructor Summary
Constructors Constructor Description MockMavericksViewModelConfigFactory(Context applicationContext, Boolean debugMode, CoroutineContext viewModelCoroutineContext, CoroutineContext stateStoreCoroutineContext, CoroutineContext subscriptionCoroutineContextOverride)
-
Method Summary
Modifier and Type Method Description final Map<MavericksStateStore<?>, MockableMavericksViewModelConfig<?>>getCurrentConfigs()final MockBehaviorgetMockBehavior()Determines what sort of mocked state store is created when provideConfig is called. final UnitsetMockBehavior(MockBehavior mockBehavior)Determines what sort of mocked state store is created when provideConfig is called. final CoroutineContextgetContextOverride()final BooleangetDebugMode()final CoroutineContextgetStoreContextOverride()final CoroutineContextgetSubscriptionCoroutineContextOverride()final <R extends Any> RwithMockBehavior(MockBehavior mockBehavior, Function0<R> block)Any view models created within the block will be given a viewmodel store that was created according to the rules of the given mock behavior. <S extends MavericksState> MavericksViewModelConfig<S>buildConfig(MavericksViewModel<S> viewModel, S initialState)final UnitpushMockBehaviorOverride(MockBehavior mockBehavior)Changes the current MockBehavior of all running ViewModels, if they were created when mockBehavior was non null. final UnitpushMockBehaviorOverride(Function1<MockBehavior, MockBehavior> behaviorChange)final UnitpopMockBehaviorOverride()final UnitaddOnExecuteListener(Function3<MavericksViewModelConfig<?>, MavericksViewModel<?>, MavericksBlockExecutions, Unit> listener)Add a lambda that will be invoked whenever MavericksViewModel.execute is used. final UnitremoveOnExecuteListener(Function3<MavericksViewModelConfig<?>, MavericksViewModel<?>, MavericksBlockExecutions, Unit> listener)-
Methods inherited from class com.airbnb.mvrx.mocking.MockMavericksViewModelConfigFactory
addOnConfigProvidedListener, coroutineScope, removeOnConfigProvidedListener -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
MockMavericksViewModelConfigFactory
MockMavericksViewModelConfigFactory(Context applicationContext, Boolean debugMode, CoroutineContext viewModelCoroutineContext, CoroutineContext stateStoreCoroutineContext, CoroutineContext subscriptionCoroutineContextOverride)
-
-
Method Detail
-
getCurrentConfigs
final Map<MavericksStateStore<?>, MockableMavericksViewModelConfig<?>> getCurrentConfigs()
-
getMockBehavior
final MockBehavior getMockBehavior()
Determines what sort of mocked state store is created when provideConfig is called. This can be changed via withMockBehavior to affect behavior when creating a new Fragment.
A value can also be set directly here if you want to change the global default.
-
setMockBehavior
final Unit setMockBehavior(MockBehavior mockBehavior)
Determines what sort of mocked state store is created when provideConfig is called. This can be changed via withMockBehavior to affect behavior when creating a new Fragment.
A value can also be set directly here if you want to change the global default.
-
getContextOverride
final CoroutineContext getContextOverride()
-
getDebugMode
final Boolean getDebugMode()
-
getStoreContextOverride
final CoroutineContext getStoreContextOverride()
-
getSubscriptionCoroutineContextOverride
final CoroutineContext getSubscriptionCoroutineContextOverride()
-
withMockBehavior
final <R extends Any> R withMockBehavior(MockBehavior mockBehavior, Function0<R> block)
Any view models created within the block will be given a viewmodel store that was created according to the rules of the given mock behavior. The default value may have been set by a wrapping call to withMockBehavior (ie if multiple calls to withMockBehavior are nested the most recent call can change the behavior of the outer call)
After the block has executed, the previous setting for mockBehavior will be used again.
- Parameters:
mockBehavior- Null to have ViewModels created with a RealMvRxStateFactory.
-
buildConfig
<S extends MavericksState> MavericksViewModelConfig<S> buildConfig(MavericksViewModel<S> viewModel, S initialState)
-
pushMockBehaviorOverride
final Unit pushMockBehaviorOverride(MockBehavior mockBehavior)
Changes the current MockBehavior of all running ViewModels, if they were created when mockBehavior was non null. This forces the mock behavior to this new value.
This should be followed later by a corresponding call to popMockBehaviorOverride in order to revert the mock behavior to its original value.
-
pushMockBehaviorOverride
final Unit pushMockBehaviorOverride(Function1<MockBehavior, MockBehavior> behaviorChange)
-
popMockBehaviorOverride
final Unit popMockBehaviorOverride()
-
addOnExecuteListener
final Unit addOnExecuteListener(Function3<MavericksViewModelConfig<?>, MavericksViewModel<?>, MavericksBlockExecutions, Unit> listener)
Add a lambda that will be invoked whenever MavericksViewModel.execute is used.
-
removeOnExecuteListener
final Unit removeOnExecuteListener(Function3<MavericksViewModelConfig<?>, MavericksViewModel<?>, MavericksBlockExecutions, Unit> listener)
-
-
-
-