UserExceptionAction<St> class Null safety
If you want the UserExceptionDialog to display some UserException,
you must throw the exception from inside an action's before
or reduce
methods.
However, sometimes you need to create some callback that throws
an UserException. If this callback is be called outside of an action,
the dialog will not display the exception. To solve this, the callback
should not throw an exception, but instead call the UserExceptionAction,
which will then simply throw the exception in its reduce
method.
- Inheritance
- Object
- ReduxAction<
St> - UserExceptionAction
Constructors
- UserExceptionAction(String msg, {Object? cause, ExceptionCode? code})
- UserExceptionAction.from(UserException exception)
Properties
-
dispatch
→ Dispatch<
St> -
read-only, inherited
-
dispatchFuture
→ DispatchFuture<
St> -
read-only, inherited
- exception → UserException
-
final
- hasFinished → 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.
read-only, inherited
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
- state → St
-
read-only, inherited
- stateTimestamp → DateTime
-
read-only, inherited
- status → ActionStatus?
-
read-only, inherited
-
store
→ Store<
St> -
read-only, inherited
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 -
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>
).inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
reduce(
) → Future< St> -
The
reduce
method is the action reducer. It may read the action state, the store state, and then return a new state (ornull
if no state change is necessary). [...]override -
reduceWithState(
Store< St> store, St state) → FutureOr<St?> -
Nest state reducers without dispatching another action.
Example: return AddTaskAction(demoTask).reduceWithState(state);
@Deprecated("This is deprecated and will be removed soon, " "because it's more difficult to use than it seems. " "Unless you completely understand what you're doing," "you should only used it with sync reducers."), inherited
-
setStore(
Store< St> store) → void -
inherited
-
toString(
) → String -
A string representation of this object. [...]
inherited
-
wrapError(
dynamic error) → 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< St> reduce) → Reducer<St> -
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
Operators
-
operator ==(
Object other) → bool -
The equality operator. [...]
inherited