Why do we have =>
twice. Not able to understand the arrow function declaration.
const asyncFunctionMiddleware = storeAPI => next => action => {
// If the "action" is actually a function instead...
if (typeof action === 'function') {
// then call the function and pass `dispatch` and `getState` as arguments
return action(storeAPI.dispatch, storeAPI.getState)
}
// Otherwise, it's a normal action - send it onwards
return next(action)
}
asyncFunctionMiddleware
takes one argument storeAPI
and returns an unnamed function. This unnamed function takes one argument next
and returns another unnamed function. This unnamed function takes one argument action
and returns a value.