aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/framework/src/middleware/logger.ts
blob: e47484fbf6ce25ff7fc4b45e139036e069823ad6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { Dispatch } from '../flux/store';
import { MiddlewareApi } from '../store/applicationStore';


function createLoggerMiddleware() {
  return function logger({ getState }: MiddlewareApi) {
    return (next: Dispatch): Dispatch => action => {
      console.log('will dispatch', action);
      const returnValue = next(action);
      console.log('state after dispatch', getState());
      return returnValue;
    };
  }
}

export const logger = createLoggerMiddleware();
export default logger;