8
const logger = store => next => action => {
    let result
    console.groupCollapsed("dispatching", action.type)
    console.log('prev state', store.getState())
    console.log('action', action)
    result = next(action)
    console.log('next state', store.getState())
    console.groupEnd()
    return result
}

const store = applyMiddleware(logger)(createStore)(
    combineReducers({ colors, sort })
)

Would you please explain the above function with multiple arrows?

Cerbrus
  • 70,800
  • 18
  • 132
  • 147
Vikram Babu Nagineni
  • 3,411
  • 6
  • 25
  • 34

1 Answers1

24

The code below:

const logger = store => next => action => { return 'something'; }

Is the equivalent of:

const logger = function(store) { 
    return function(next) {
        return function(action) {
            return 'something';
        }
    }
}

And it can be called like below:

var something = logger(store)(next)(action);
Faly
  • 13,291
  • 2
  • 19
  • 37