Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I read the following arrow function

Tags:

javascript

How can I read the following arrow function in English? I can understand that there are 2 parameters namely dispatch and getState. How do I read the remaining part?

How to write it as a normal function?

    const apiMiddleware = ({ dispatch, getState}) => next => action => {  
like image 520
jupiter sailormoon Avatar asked Nov 06 '22 23:11

jupiter sailormoon


1 Answers

Written as a normal function, the declaration will look like this:

const apiMiddleware = function({ dispatch, getState}){
 return function(next) {
    return function(action) {
      return something;
  }
 }
} 

I suggest you to read this great article about higher order arrow functions here

like image 116
Stundji Avatar answered Nov 15 '22 07:11

Stundji