Ran into some code that looks like the following:
return store => next => action => {
switch(action.type) {
...
default:
return next(action)
};
The entire sample is here: https://exec64.co.uk/blog/websockets_with_redux/
What is the triple arrow syntax here? I'm familiar with arrow functions, but I've never seen more than one used before to define a function.
It is an arrow function with argument store
which returns another arrow function with argument next
which returns another one with argument action
. Analogy with regular functions would be:
return function (store) {
return function(next) {
return function(action) {
switch(action.type) {
...
default:
return next(action)
}
}
}
Just to notice that this syntax:
const myFunction = someParam => someValue
is shorthand for:
const myFunction = someParam => {
return someValue
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.