MockStore<St> class
Creates a Redux store that lets you mock actions/reducers.
The MockStore lets you define mock actions/reducers for specific actions.
For more info, see: https://pub.dartlang.org/packages/async_redux
Constructors
-
MockStore({required St initialState, bool syncStream = false, TestInfoPrinter? testInfoPrinter, List<
ActionObserver< ? actionObservers, List<St> >StateObserver< ? stateObservers, Persistor<St> >St> ? persistor, ModelObserver? modelObserver, ErrorObserver<St> ? errorObserver, WrapError<St> ? wrapError, bool defaultDistinct = true, Map<Type, dynamic> ? mocks})
Properties
- defaultDistinct → bool
-
no setterinherited
- dispatchCount → int
-
no setterinherited
- env → Object?
-
no setterinherited
-
errors
→ Queue<
UserException> -
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- immutableCollectionEquality → CompareBy?
-
If
null
(the default), view-models which are immutable collections will be compared by their default equality.If
CompareBy.byDeepEquals
, view-models which are immutable collections will be compared by their items, one by one (potentially slow comparison).If
CompareBy.byIdentity
, view-models which are immutable collections will be compared by their internals being identical (very fast comparison).no setterinherited - isShutdown → bool
-
no setterinherited
-
mocks
↔ Map<
Type, dynamic> ? -
null
to disable dispatching the action of a certain type.A
MockAction<St>
instance to dispatch that action instead, and provide the original action as a getter to the mocked action.A
ReduxAction<St>
instance to dispatch that mocked action instead.ReduxAction<St> Function(ReduxAction<St>)
to create a mock from the original action.St Function(ReduxAction<St>, St)
orFuture<St> Function(ReduxAction<St>, St)
to modify the state directly.getter/setter pair - modelObserver → ModelObserver?
-
no setterinherited
-
onChange
→ Stream<
St> -
A stream that emits the current state when it changes.
no setterinherited
-
onReduce
→ Stream<
TestInfo< St> > -
Used by the storeTester.
no setterinherited
- reduceCount → int
-
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → St
-
The current state of the app.
no setterinherited
- stateTimestamp → DateTime
-
The timestamp of the current state in the store, in UTC.
no setterinherited
- testInfoPrinter → TestInfoPrinter?
-
no setterinherited
Methods
-
addMock(
Type actionType, dynamic mock) → MockStore< St> -
addMocks(
Map< Type, dynamic> mocks) → MockStore<St> -
clearMocks(
) → MockStore< St> -
createTestInfoSnapshot(
St state, ReduxAction< St> action, Object? error, Object? processedError, {required bool ini}) → void -
inherited
-
defineState(
St state) → void -
Beware: Changes the state directly. Use only for TESTS.
inherited
-
deleteStateFromPersistence(
) → Future< void> -
Asks the Persistor to delete the saved state from the local persistence.
inherited
-
dispatch(
ReduxAction< St> action, {bool notify = true}) → FutureOr<ActionStatus> -
Runs the action, applying its reducer, and possibly changing the store state.
Note: dispatch is of type Dispatch.
override
-
dispatchAsync(
ReduxAction< St> action, {bool notify = true}) → Future<ActionStatus> -
Runs the action, applying its reducer, and possibly changing the store state.
Note: dispatchAsync is of type DispatchAsync.
override
-
dispatchSync(
ReduxAction< St> action, {bool notify = true}) → ActionStatus -
Runs the action, applying its reducer, and possibly changing the store state.
Note: dispatchSync is of type DispatchSync.
override
-
getAndRemoveFirstError(
) → UserException? -
Gets the first error from the error queue, and removes it from the queue.
inherited
-
getLastPersistedStateFromPersistor(
) → St? -
Gets, from the Persistor, the last state that was saved to the local persistence.
inherited
-
initTestInfoController(
) → void -
Turns on testing capabilities, if not already.
inherited
-
initTestInfoPrinter(
TestInfoPrinter testInfoPrinter) → void -
Changes the testInfoPrinter.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pausePersistor(
) → void -
Pause the Persistor temporarily.
inherited
-
persistAndPausePersistor(
) → void -
Persists the current state (if it's not yet persisted), then pauses the Persistor
temporarily.
inherited
-
readStateFromPersistence(
) → Future< St?> -
Asks the Persistor to read the state from the local persistence.
Important: If you use this, you MUST put this state into the store.
The Persistor will assume that's the case, and will not work properly otherwise.
inherited
-
resumePersistor(
) → void -
Resumes persistence by the Persistor,
after calling pausePersistor or persistAndPausePersistor.
inherited
-
saveInitialStateInPersistence(
St initialState) → Future< void> -
Asks the Persistor to save the
initialState
in the local persistence.inherited -
shutdown(
) → void -
Call this method to shut down the store.
It won't accept dispatches or change the state anymore.
inherited
-
teardown(
{St? emptyState}) → Future -
Closes down the store so it will no longer be operational.
Only use this if you want to destroy the Store while your app is running.
Do not use this method as a way to stop listening to onChange state changes.
For that purpose, view the onChange documentation.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
waitCondition(
bool condition(St), {int? timeoutInSeconds}) → Future< void> -
Returns a future which will complete when the given
condition
is true. The condition can access the state. You may also provide atimeoutInSeconds
, which by default is null (never times out).inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited