ReactterAction<T> constructor
const
ReactterAction<T> ({
- required String type,
- required T payload,
A representation of an event that describes something that happened in the application.
A ReactterAction is composed of two properties:
- The type property, which provides this action a name that is descriptive.
- The payload property, which contain an action object type of
T
that can provide additional information about what happened.
A typical ReactterAction might look like this:
class AddTodoAction extends ReactterAction<String> {
AddTodoAction(String payload)
: super(
type: 'todo/todoAdded',
payload: payload,
);
}
and use with UseReducer dispatch
, like:
// Consult `UseReducer` for more information about `reducer` and `store`.
final state = UseReducer(reducer, store);
state.dispatch(AddTodoAction('Todo this'));
See also:
- UseReducer, a ReactterHook that manages state using
reducer
method.
Implementation
const ReactterAction({
required this.type,
required this.payload,
});