Middleware<State> typedef

Middleware<State> = dynamic Function(Store<State> store, dynamic action, NextDispatcher next)

A function that intercepts actions and potentially transform actions before they reach the reducer.

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.

Example

loggingMiddleware(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: [loggingMiddleware],
);

Implementation

typedef Middleware<State> = dynamic Function(
  Store<State> store,
  dynamic action,
  NextDispatcher next,
);