@@ -25,23 +25,24 @@ class MiddlewareApi<State extends BuiltReducer<State, StateBuilder>,
2525/// Action<T>, and a builder of type StateBuilder
2626class MiddlewareBuilder <State extends BuiltReducer <State , StateBuilder >,
2727 StateBuilder extends Builder <State , StateBuilder >, Actions extends ReduxActions > {
28- var _map = new Map <String , MiddlewareHandler <State , StateBuilder , Actions >>();
28+ var _map = new Map <String , MiddlewareHandler <State , StateBuilder , Actions , dynamic >>();
2929
30- void add <T >(ActionName <T > aMgr, MiddlewareHandler <State , StateBuilder , Actions > handler) {
30+ void add <T >(ActionName <T > aMgr, MiddlewareHandler <State , StateBuilder , Actions , T > handler) {
3131 _map[aMgr.name] = handler;
3232 }
3333
3434 /// build returns a [Middleware] function that handles all actions added with [add]
3535 Middleware <State , StateBuilder , Actions > build () =>
36- (MiddlewareApi <State , StateBuilder , Actions > api) => (ActionHandler next) => (Action action) {
37- var handler = _map[action.name];
38- if (handler != null ) {
39- handler (api, next, action);
40- return ;
41- }
42-
43- next (action);
44- };
36+ (MiddlewareApi <State , StateBuilder , Actions > api) =>
37+ (ActionHandler next) => (Action <dynamic > action) {
38+ var handler = _map[action.name];
39+ if (handler != null ) {
40+ handler (api, next, action);
41+ return ;
42+ }
43+
44+ next (action);
45+ };
4546}
4647
4748/// [MiddlewareHandler] is a function that handles an action in a middleware. Its is only for
@@ -50,4 +51,5 @@ class MiddlewareBuilder<State extends BuiltReducer<State, StateBuilder>,
5051typedef void MiddlewareHandler <
5152 State extends BuiltReducer <State , StateBuilder >,
5253 StateBuilder extends Builder <State , StateBuilder >,
53- Actions extends ReduxActions >(MiddlewareApi <State , StateBuilder , Actions > api, ActionHandler next, Action action);
54+ Actions extends ReduxActions ,
55+ Payload >(MiddlewareApi <State , StateBuilder , Actions > api, ActionHandler next, Action <Payload > action);
0 commit comments