BaseState<T> class

Every state class must derived from BaseState<T> class. And it is mandatory to pass the state name and initialState.

Example:

class CounterModel {
  final int count;
  final bool isLoading;
  CounterModel({this.count, this.isLoading});
  CounterModel.init():this(count:0, isLoading:false);
  CounterModel.countData(int count) : this(count: count, isLoading: false);
}

class CounterState extends BaseState<CounterModel> {

  CounterState(): super(name: 'counter', initialState: CounterModel.init());


  CounterModel reduce(CounterModel state, Action action) {
    switch (action.type) {
      case ActionTypes.Inc: return CounterModel.countData(state.count+1);
      default: return state;
    }
  }
}

Constructors

BaseState({@required String name, @required T initialState })

Properties

initialState → T
final
name → String
final
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

mapActionToState(T state, Action action) → Stream<T>
This method should be invoked by sysytem passing current state and action. You should mutate the state based on action [...]
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 ==(dynamic other) → bool
The equality operator. [...]
inherited