MiddlewareClass<State> class

Defines a Middleware using a Class interface.

Middleware intercept actions before they reach the reducer. This gives them the ability to produce side-effects or modify the passed in action before they reach the reducer.

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

Example

class LoggingMiddleware extends MiddlewareClass<int> {
  call(Store<int> store, action, NextDispatcher next) {
    print('${new DateTime.now()}: $action');

    next(action);
  }
}

// Create your store with the loggingMiddleware
final store = new Store<int>(
  counterReducer,
  middleware: [new LoggingMiddleware()],
);
Implementers

Constructors

MiddlewareClass()

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(Store<State> store, dynamic action, NextDispatcher next) → dynamic
A Middleware function that intercepts a dispatched 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 ==(Object other) bool
The equality operator. [...]
inherited