ReactterActionCallable<T, P> class abstract

A abstract class of ReactterAction that may be called using a call method.

Example:

class AddTodoAction extends ReactterActionCallable<Store, String> {
  AddTodoAction(String payload)
    : super(
        type: 'todo/todoAdded',
        payload: payload,
      );

  Store call(state) {
    return state.copyWith(
      todo: state.todo..add(payload),
    );
  }
}

Store _reducer(Store state, ReactterAction action) =>
  action is ReactterActionCallable ? action(state) : UnimplementedError()

final state = UseReducer(_reducer, Store());

state.dispatch(AddTodoAction('Todo this'));

See also:

Inheritance

Constructors

ReactterActionCallable({required String type, required P payload})
const

Properties

hashCode int
The hash code for this object.
no setterinherited
payload → P
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type String
finalinherited

Methods

call(T state) → T
This method is called when the action is dispatched and is responsible for updating the state based on the action's payload.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited