1A Redux middleware is a function returning a function, which takes next as a
2 parameter. Then the inner function returns another function which takes action
3as a parameter and finally returns next(action). Here's how it looks like:
4
5function Middleware() {
6  return function(next){
7    return function(action){
8      // do your stuff
9      return next(action);
10    }
11  }
12}1const loggingMiddleware = function(store) {
2  // Called when calling applyMiddleware so
3  // our middleware can have access to the store
4
5  return function(next) {
6    // next is the following action to be run
7    // after this middleware
8
9    return function(action) {
10      // finally, this is where our logic lives for
11      // our middleware.
12    }
13  }
14}
151import * as types from './types';
2
3export const initialState = {
4  currentTime: new Date().toString(),
5}
6
7export const reducer = (state = initialState, action) => {
8  switch(action.type) {
9    case types.FETCH_NEW_TIME:
10      return { ...state, currentTime: action.payload}
11    default:
12      return state;
13  }
14}
15
16export default reducer
17