MessageFormatter<State> typedef
A function that formats the message that will be logged. By default, the action, state, and timestamp will be printed on a single line.
This package ships with two formatters out of the box:
Example
// Create a formatter that only prints out the dispatched action
String onlyLogActionFormatter<State>(
State state,
action,
DateTime timestamp,
) {
return '{Action: $action}';
}
// Create your middleware using the formatter.
final middleware = new LoggingMiddleware(formatter: onlyLogActionFormatter);
// Add the middleware to your Store
final store = new Store<int>(
(int state, action) => state + 1,
initialState: 0,
middleware: [middleware],
);
Implementation
typedef MessageFormatter<State> = String Function(
State state,
dynamic action,
DateTime timestamp,
);