ReducerClass<State> class

Defines a Reducer using a class interface.

Implement this class to modify your app state in response to a given action.

For some use cases, a class may be preferred to a function. In these instances, a ReducerClass can be used.

Example

class CounterReducer extends ReducerClass<int> {
  int call(int state, action) {
    switch (action) {
      case 'INCREMENT':
        return state + 1;
      case 'DECREMENT':
        return state - 1;
      default:
        return state;
    }
  }
}

final store = new Store<int>(new CounterReducer());
Implementers

Constructors

ReducerClass()

Properties

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

Methods

call(State state, dynamic action) → State
The Reducer function that converts the current state and action into a new state
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

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