es6 curry function
es6 curry function
// vuex getters
export const getAdsFilterConfig = (state) => (spreader) => {
console.log('state =', state)
console.log('spreader =', spreader)
return state[spreader];
};
// this.getAdsFilterConfig(this.spreaderAlias);
// export const stateActivity = state => state.stateActivity;
equal to
// getter 自动执行,getter func === func()
export const getAdsFilterConfig = (state) => {
// state 来自 store 上下文
return (spreader) => {
return state[spreader];
};
}
https://codesandbox.io/s/vuex-store-getter-es6-curry-function-n7prr?file=/src/main.js



bug

state = {k: 1};
// {k: 1}
getAdsFilterConfig = (state) => (spreader) => {
return state[spreader];
};
/*
(state) => (spreader) => {
return state[spreader];
}
*/
getAdsFilterConfig(`k`);
/*
(spreader) => {
return state[spreader];
}
*/
getAdsFilterConfig()(`k`);
// Uncaught TypeError: Cannot read property 'k' of undefined
vuex
const store = new Vuex.Store({
state: {
todos: [
{ id: 1, text: '...', done: true },
{ id: 2, text: '...', done: false }
]
},
getters: {
doneTodos: state => {
return state.todos.filter(todo => todo.done)
}
}
})
https://vuex.vuejs.org/guide/getters.html#method-style-access

refs
xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
es6 curry function的更多相关文章
- vue & lifecycle methods & this bug & ES6 Arrow function & this bind bug
vue & lifecycle methods & this bug ES6 Arrow function & this bind bug bad fetchTableData ...
- ES6 Arrow Function & this bug
ES6 Arrow Function & this bug let accHeadings = document.querySelectorAll(`.accordionItemHeading ...
- ES6 Arrow Function All In One
ES6 Arrow Function All In One this const log = console.log; const arrow_func = (args) => log(`arg ...
- ES6 arrow function vs ES5 function
ES6 arrow function vs ES5 function ES6 arrow function 与 ES5 function 区别 this refs xgqfrms 2012-2020 ...
- ES6 Arrow Function return Object
ES6 Arrow Function return Object https://github.com/lydiahallie/javascript-questions/issues/220#issu ...
- ES6 arrow function
语法: () => { … } // 零个参数用 () 表示: x => { … } // 一个参数可以省略 (): (x, y) => { … } // 多参数不能省略 (): 当 ...
- JavaScript- The Good Parts function Curry
Functions are values, and we can manipulate function values in interesting ways.Currying allows us t ...
- Function Programming - 柯里化(curry)
看到一篇非常不错的文章,这里分享给大家:http://www.jianshu.com/p/fa3568087881. 首先,柯里化的定义:你可以只透过部分的参数呼叫一个function,它会回传一个f ...
- [ES6] 06. Arrow Function =>
ES6 arrow function is somehow like CoffeeScirpt. CoffeeScript: //function call coffee = -> coffee ...
随机推荐
- 处理K8S PVC删除后pod报错
报错如下 Jun 19 17:15:18 node1 kubelet[1722]: E0619 17:15:18.381558 1722 desired_state_of_world_populato ...
- 监听套接字描述字 已连接套接字描述字 和打电话的情形非常不一样的地方 完成了 TCP 三次握手,操作系统内核就为这个客户生成一个已连接套接字
1. accept: 电话铃响起了-- 当客户端的连接请求到达时,服务器端应答成功,连接建立,这个时候操作系统内核需要把这个事件通知到应用程序,并让应用程序感知到这个连接.这个过程,就好比电信运营商完 ...
- (Mysql)连接问题之1130
访问远程服务器上的Mysql数据库连接是报:1130-host is not allowed to connect this MYSQL severe; 解决方案: 登录远程服务器下的mysql下. ...
- is == id ,编码
一. id 查询内存地址. # name = 'alex' # print(id(name)) # name1 = 'alex' # name2 = 'alex' # print(name1 == n ...
- cdq分治 笔记
算法讲解 这个算法用于解决三维偏序问题. 三维偏序:给定 \(n\) 个三元组: \((a_i,b_i,c_i)\),求同时满足满足 \(a_i\le a_j,b_i\le b_j,c_i\le c_ ...
- power network 电网——POJ1459
Power Network Time Limit: 2000MS Memory Limit: 32768K Total Submissions: 27282 Accepted: 14179 D ...
- SpringBoot使用SpringDataJPA完成CRUD
创建UserJPA接口并且继承SpringDataJPA内的接口作为父类: UserJPA继承了JpaRepository接口(SpringDataJPA提供的简单数据操作接口).JpaSpecifi ...
- MapReduce编程练习(三),按要求不同文件名输出结果
问题:按要求文件名输出结果,比如这里我要求对一个输入文件中的WARN,INFO,ERROR,的信息项进行分析,并分别输入到对应的以WARN,INFO.ERROR和OTHER开头的结果文件中,其中结果文 ...
- 武装你的WEBAPI-OData资源更新Delta
本文属于OData系列 目录 武装你的WEBAPI-OData入门 武装你的WEBAPI-OData便捷查询 武装你的WEBAPI-OData分页查询 武装你的WEBAPI-OData资源更新Delt ...
- struts 返回字符串
方法一: HttpServletResponse response = ServletActionContext.getResponse(); response.getWriter().print(& ...