Reputation: 48440
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.
Upvotes: 1
Views: 362
Reputation: 51841
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
}
Upvotes: 7