blob: 3844485ecd75ac747ea080738090f8ed68813993 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import { Dispatch } from '../flux/store';
import { MiddlewareApi } from '../store/applicationStore';
function createThunkMiddleware() {
return ({ dispatch, getState }: MiddlewareApi) =>
(next : Dispatch) : Dispatch =>
action => {
if (typeof action === 'function') {
return action(dispatch, getState);
}
return next(action);
};
}
export const thunk = createThunkMiddleware();
export default thunk;
|