ran*_*its 1 javascript ecmascript-6
进入一些看起来如下的代码:
return store => next => action => {
switch(action.type) {
...
default:
return next(action)
};
Run Code Online (Sandbox Code Playgroud)
整个示例如下:https://exec64.co.uk/blog/websockets_with_redux/
这里的三箭头语法是什么?我熟悉箭头函数,但我从未见过多于一个用于定义函数的函数.
它是与参数的箭头功能store
,其与参数返回另一个箭头函数next
返回另一个带有参数action
.与常规功能类比如下:
return function (store) {
return function(next) {
return function(action) {
switch(action.type) {
...
default:
return next(action)
}
}
}
Run Code Online (Sandbox Code Playgroud)
只是要注意这个语法:
const myFunction = someParam => someValue
Run Code Online (Sandbox Code Playgroud)
是简写:
const myFunction = someParam => {
return someValue
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
236 次 |
最近记录: |