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 ...
随机推荐
- 解决window10 和 ubuntu 双系统安装没有启动选项问题
win10 和Ubuntu 双系统安装在网上已经有很多例子了,这里就不在赘述了. 今天新买的笔记本,想安装双系统.正常安装完ubuntu 重启后没有选项. 解决方法一 下载和解压以后,按照以下的步骤安 ...
- 客户端必须在它发送到服务器的所有帧中添加掩码(Mask)
在WebSocket协议中,数据是通过一系列数据帧来进行传输的.为了避免由于网络中介(例如一些拦截代理)或者一些在第10.3节讨论的安全原因,客户端必须在它发送到服务器的所有帧中添加掩码(Mask)( ...
- error out of table range
.
- Qedis实现
对比redis的Qedis 实现在github 和 实验楼都有资料
- BFS DFS与回溯
https://blog.csdn.net/u014303647/article/details/88328526 cyc: https://github.com/CyC2018/CS-Notes/b ...
- 基于navicat的数据库导入导出
1.右键当前数据库,选择转储SQL文件 选择导出sql的存放路径 2.新建统一命名的数据库,右键运行SQL文件 3,.选择要导入的SQL文件后如图
- Box Model 盒子模型
Box Model盒子模型,是初学者在学习HTMl5时会学到的一个重要的模型,也有一些人称它为框模型,因为盒子是属于3维,而框是平面的.称之为盒子模型,是因为其结构和盒子十分相似,其最外面是margi ...
- Docker+Prometheus+Alertmanager+Webhook钉钉告警
Docker+Prometheus+Alertmanager+Webhook钉钉告警 1.环境部署 1.1 二进制部署 1.2 docker部署 1.2.1 webhook 1.2.2 alertma ...
- java中的IO处理和使用,API详细介绍(二)
字符流 [向文件中写入数据] 现在我们使用字符流 /** * 字符流 * 写入数据 * */ import java.io.*; class hello{ public static void mai ...
- 链表中head->next = p;和p=head->next;之间的区别
最近这两天在看递归,然后,看了几个例子,其中有一个单链表反转的例子可以使用递归解决,但是这里却有一个问题让我迷惑了一会,就是链表操作中这两句话的含义: 以下图中的单向链表为例: Node preNod ...