BaseAction class
A ReduxAction wrapper for Action objects and provides all necessary utilities needed to interact with the Store and the Navigator.
- Inheritance
-
- Object
- ReduxAction<
AppState> - BaseAction
- Implemented types
Constructors
- BaseAction()
-
BaseAction.build(Map<
String, dynamic> data) - Builds anonymous actions
Properties
-
dispatch
→ Dispatch<
AppState> -
Dispatches the action, applying its reducer, and possibly changing the store state.
The action may be sync or async.
no setterinherited
-
dispatchAndWait
→ DispatchAndWait<
AppState> -
Dispatches the action, applying its reducer, and possibly changing the store state.
The action may be sync or async. In both cases, it returns a Future that resolves when
the action finishes.
no setterinherited
-
dispatchAsync
→ DispatchAsync<
AppState> -
no setterinherited
-
dispatchSync
→ DispatchSync<
AppState> -
Dispatches the action, applying its reducer, and possibly changing the store state.
However, if the action is ASYNC, it will throw a StoreException.
no setterinherited
- env → Object?
-
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isFinished → bool
-
Returns true only if the action finished with no errors.
In other words, if the methods before, reduce and after all finished executing
without throwing any errors.
no setterinherited
- microtask → Future
-
To wait for the next microtask:
await microtask;
no setterinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → AppState
-
no setterinherited
- stateTimestamp → DateTime
-
no setterinherited
- status → ActionStatus
-
no setterinherited
-
store
→ Store<
AppState> -
no setterinherited
Methods
-
abortDispatch(
) → bool -
If this returns true, the action will not be dispatched:
before
,reduce
andafter
will not be called, and the action will not be visible to theStoreTester
. This is only useful under rare circumstances, and you should only use it if you know what you are doing.inherited -
after(
) → void -
This is an optional method that may be overridden to run during action
dispatching, after
reduce
. If this method throws an error, the error will be swallowed (will not throw). So you should only run code that can't throw errors. It may be synchronous only. Note this method will always be called, even if errors were thrown bybefore
orreduce
.inherited -
assertUncompletedFuture(
) → void -
An async reducer (one that returns Future<AppState?>) must never complete without at least
one await, because this may result in state changes being lost. It's up to you to make sure
all code paths in the reducer pass through at least one
await
.inherited -
before(
) → FutureOr< void> -
This is an optional method that may be overridden to run during action
dispatching, before
reduce
. If this method throws an error, thereduce
method will NOT run, but the methodafter
will. It may be synchronous (returningvoid
) ou async (returningFuture<void>
). You should NOT returnFutureOr
.inherited -
dispatchAction(
ReduxAction< AppState> action) → Future<void> -
Dispatches an action.
override
-
dispatchModel<
Model extends BaseUIModel> (Model defaultModel, void f(Model m), [bool overwrite = false]) → Future< void> -
Sends an anonymous action given the data of a model of type BaseUIModel
override
-
mutate<
Model extends BaseUIModel> (Model defaultModel, void f(Model m), [bool overwrite = false]) → Model - Modifies the data of the model of type BaseUIModel stored the store
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pop(
) → void -
Removes the current route from the navigation stack
override
-
popUntil(
bool predicate(Route)) → void -
Removes all routes in the navigation stack until the condition specified in
predicate
is satisfiedoverride -
push(
Route route) → void -
Puts a route object on top of the navigation stack
override
-
pushNamed(
String route, {Object? arguments}) → void -
Puts a route on top of the navigation stack
override
-
pushNamedAndRemoveAll(
String route, {Object? arguments}) → void -
Adds a route into the navigation stack and removes everything else
override
-
pushNamedAndRemoveUntil(
String route, {Object? arguments, RoutePredicate? predicate}) → void -
Adds a route into the navigation stack and removes everything until the condition
specified in
predicate
is satisfiedoverride -
pushReplacementNamed(
String route, {Object? arguments}) → void -
Replaces the current route with the specified route
override
-
read<
Model extends BaseUIModel> (Model defaultModel) → Model - Reads a model of type BaseUIModel from the store
-
reduce(
) → Future< AppState?> -
An override to the ReduxAction.reduce to allow processing of anonymous actions
override
-
reduceWithState(
Store< AppState> store, AppState state) → FutureOr<AppState?> -
Nest state reducers without dispatching another action.
Example: return AddTaskAction(demoTask).reduceWithState(state);
inherited
-
runtimeTypeString(
) → String -
Returns the runtimeType, without the generic part.
inherited
-
setStore(
Store< AppState> store) → void -
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
wrapError(
Object error, StackTrace stackTrace) → Object? -
If any error is thrown by
reduce
orbefore
, you have the chance to further process it by usingwrapError
. Usually this is used to wrap the error inside of another that better describes the failed action. For example, if some action converts a String into a number, then instead of throwing a FormatException you could do:inherited -
wrapReduce(
Reducer< AppState> reduce) → Reducer<AppState> -
You may wrap the reducer to allow for some pre or post-processing.
For example, if you want to abort an async reducer if the state
changed since when the reducer started:
inherited
-
write<
Model extends BaseUIModel> (Model defaultModel, void f(Model m), [bool overwrite = false]) → AppState - Writes the data of the model of type BaseUIModel in the store
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited