-
- All Implemented Interfaces:
-
com.airbnb.mvrx.MavericksStateStore,com.airbnb.mvrx.ScriptableStateStore,com.airbnb.mvrx.mocking.MockableStateStore
public final class MockableMavericksStateStore<S extends MavericksState> implements MockableStateStore<S>
Allows switching between a mocked state store and a real state store behavior. This is intended to enable testing.
When StateStoreBehavior.Scriptable behavior is set, next can be called to force a state synchronously. When in this mode, calls to set have no effect. In other modes, it is an error to call next.
The mode can be dynamically changed to modify behavior at runtime.
-
-
Field Summary
Fields Modifier and Type Field Description private final Sstateprivate final Flow<S>flowprivate MockBehaviormockBehaviorprivate final CoroutineScopecoroutineScope
-
Constructor Summary
Constructors Constructor Description MockableMavericksStateStore(S initialState, MockBehavior mockBehavior, CoroutineScope coroutineScope, CoroutineContext contextOverride)
-
Method Summary
Modifier and Type Method Description SgetState()Flow<S>getFlow()MockBehaviorgetMockBehavior()UnitsetMockBehavior(MockBehavior mockBehavior)final CoroutineScopegetCoroutineScope()Unitnext(S state)Unitget(Function1<S, Unit> block)Unitset(Function1<S, S> stateReducer)final UnitaddOnStateSetListener(Function2<S, S, Unit> callback)Add a listener that will be called each time a state is set on this state store via the set function. final UnitremoveOnStateSetListener(Function2<S, S, Unit> callback)final UnitaddOnCancelListener(Function1<MockableMavericksStateStore<?>, Unit> callback)-
-
Constructor Detail
-
MockableMavericksStateStore
MockableMavericksStateStore(S initialState, MockBehavior mockBehavior, CoroutineScope coroutineScope, CoroutineContext contextOverride)
-
-
Method Detail
-
getMockBehavior
MockBehavior getMockBehavior()
-
setMockBehavior
Unit setMockBehavior(MockBehavior mockBehavior)
-
getCoroutineScope
final CoroutineScope getCoroutineScope()
-
addOnStateSetListener
final Unit addOnStateSetListener(Function2<S, S, Unit> callback)
Add a listener that will be called each time a state is set on this state store via the set function.
-
removeOnStateSetListener
final Unit removeOnStateSetListener(Function2<S, S, Unit> callback)
-
addOnCancelListener
final Unit addOnCancelListener(Function1<MockableMavericksStateStore<?>, Unit> callback)
-
-
-
-