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的更多相关文章

  1. vue & lifecycle methods & this bug & ES6 Arrow function & this bind bug

    vue & lifecycle methods & this bug ES6 Arrow function & this bind bug bad fetchTableData ...

  2. ES6 Arrow Function & this bug

    ES6 Arrow Function & this bug let accHeadings = document.querySelectorAll(`.accordionItemHeading ...

  3. ES6 Arrow Function All In One

    ES6 Arrow Function All In One this const log = console.log; const arrow_func = (args) => log(`arg ...

  4. ES6 arrow function vs ES5 function

    ES6 arrow function vs ES5 function ES6 arrow function 与 ES5 function 区别 this refs xgqfrms 2012-2020 ...

  5. ES6 Arrow Function return Object

    ES6 Arrow Function return Object https://github.com/lydiahallie/javascript-questions/issues/220#issu ...

  6. ES6 arrow function

    语法: () => { … } // 零个参数用 () 表示: x => { … } // 一个参数可以省略 (): (x, y) => { … } // 多参数不能省略 (): 当 ...

  7. JavaScript- The Good Parts function Curry

    Functions are values, and we can manipulate function values in interesting ways.Currying allows us t ...

  8. Function Programming - 柯里化(curry)

    看到一篇非常不错的文章,这里分享给大家:http://www.jianshu.com/p/fa3568087881. 首先,柯里化的定义:你可以只透过部分的参数呼叫一个function,它会回传一个f ...

  9. [ES6] 06. Arrow Function =>

    ES6 arrow function is somehow like CoffeeScirpt. CoffeeScript: //function call coffee = -> coffee ...

随机推荐

  1. Serverless对研发效能的变革和创新 云托管和Serverless应用差异

    https://mp.weixin.qq.com/s/J4RXtKanh3IMr4fY7t0nyQ Serverless对研发效能的变革和创新 杨皓然(不瞋) 阿里巴巴中间件 2020-10-23

  2. 每天响应数亿次请求,腾讯云如何提供高可用API服务?

    每天响应数亿次请求,腾讯云如何提供高可用API服务? https://mp.weixin.qq.com/s/OPwlHcqkaTT_gcwHfr5Shw 李阳 云加社区 2020-09-16 导语 | ...

  3. XA Transactions

    XA Transactions XA is a two-phase commit protocol that is natively supported by many databases and t ...

  4. CF42A

    题意 给定两个序列 a 和 b. 序列 a 中的各个数之间的比例可以得出一个 x . 当 b 中比例满足 a 中比例,即 \(b_1\):\(b_2\):\(b_3\)-- \(=\) \(a_1\) ...

  5. Spring MVC——基础(简介,使用,地址映射)

    Spring MVC简介 重点Spring MVC的处理流程 Spring MVC特点 Spring MVC的使用 将相应的JAR包导入lib文件下 配置相关webxml 配置servlet-mvcx ...

  6. Linux常用命令详解(第三章)(ping、kill、seq、du、df、free、date、tar)

    本章命令(共7个): 1 2 3 4 5 6 7 8 ping kill seq du df free date tar 1." ping " 作用:向网络主机发送ICMP(检测主 ...

  7. CODING 联合 TKE,让应用发布更便捷

    随着互联网服务的竞争进入红海,IT 服务的复杂性加大,用户对于软件工程的速度与质量有了更高的追求.在这样的大背景下,DevOps.容器.微服务逐步取代传统的开发模式成为云原生的关键组成部分,腾讯云更是 ...

  8. 《C++ Primer Plus》啃书计 第1~4章

    <C++ Primer Plus>啃书计 第1~4章 第一章 预备知识 1.1-1.3略过 1.4 程序创建的技巧 1. cfront,它将C++源代码翻译成C源代码,然后再使用标准C编译 ...

  9. Java程序操作HBase

    package com.zy.test; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import ...

  10. C - Oulipo

    The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e ...