随笔分类 -  Compose

摘要:Many streams of events end when a certain condition is met. When we run into that condition, we'll want to pass down our own custom values. This lesso 阅读全文
posted @ 2020-11-17 02:40 Zhentiw 阅读(142) 评论(0) 推荐(0) 编辑
摘要:It's common for a user to enter values that you want to check against your pre-defined values. Let's make a demo of a word game to demonstrate one app 阅读全文
posted @ 2020-11-12 15:56 Zhentiw 阅读(139) 评论(0) 推荐(0) 编辑
摘要:In previous post, we have follow code: const delayMessage = (message) => hardCode(message)(createTimeout(1000)); const sequence = (...broadcasters) => 阅读全文
posted @ 2020-11-11 16:46 Zhentiw 阅读(125) 评论(0) 推荐(0) 编辑
摘要:Many scenarios involve one task happening after another has completed. This lesson walks you through setting up "steps" which trigger one after anothe 阅读全文
posted @ 2020-11-04 20:09 Zhentiw 阅读(68) 评论(0) 推荐(0) 编辑
摘要:Asynchronous code often uses conditions to determine when a block of code should finish running. This lesson walks through writing a doneIf operator w 阅读全文
posted @ 2020-11-04 01:07 Zhentiw 阅读(105) 评论(0) 推荐(0) 编辑
摘要:Apps often have scenarios where one event controls another. In operators, this requires passing one broadcaster in and using it to control another bro 阅读全文
posted @ 2020-11-03 16:45 Zhentiw 阅读(90) 评论(0) 推荐(0) 编辑
摘要:After a broadcaster is "done", starting it up again requires calling the broadcaster with the same listener. This creates a kind of "async recursion" 阅读全文
posted @ 2020-11-03 01:22 Zhentiw 阅读(87) 评论(0) 推荐(0) 编辑
摘要:Controlling when a broadcaster starts and stops gives you complete control over your broadcasters. This let's you hook multiple pieces of UI together 阅读全文
posted @ 2020-11-02 19:26 Zhentiw 阅读(124) 评论(0) 推荐(0) 编辑
摘要:document.getElementById("app").innerHTML = ` <h1>Hello Parcel!</h1> <div> <button id="plus">+</button> <button id="mius">-</button> </div> `; const ad 阅读全文
posted @ 2020-10-29 01:34 Zhentiw 阅读(124) 评论(0) 推荐(0) 编辑
摘要:import { curry, compose, toUpper, pipe } from 'ramda'; // #region listeners const _log = (value) => console.log(value); // #endregion // #region broad 阅读全文
posted @ 2020-10-25 22:11 Zhentiw 阅读(129) 评论(0) 推荐(0) 编辑
摘要:Buffers give you chance to gather values together until your ready to work with them. This pattern can be used for calculations, string manipulations, 阅读全文
posted @ 2020-10-25 22:10 Zhentiw 阅读(98) 评论(0) 推荐(0) 编辑
摘要:In our previous code, we have seen this partten for operators: // #region operators const concat = curry((broadcaster, listener) => { let string = ''; 阅读全文
posted @ 2020-10-25 21:54 Zhentiw 阅读(151) 评论(0) 推荐(0) 编辑
摘要:If you can think ahead to how you want your code to look into the future, then you can tackle your problems from the inside out. You design how you wa 阅读全文
posted @ 2020-10-25 21:18 Zhentiw 阅读(85) 评论(0) 推荐(0) 编辑
摘要:import { curry } from 'ramda'; // #region listeners const _log = (value) => console.log(value); // #endregion // #region broadcasters const done = Sym 阅读全文
posted @ 2020-10-25 17:45 Zhentiw 阅读(120) 评论(0) 推荐(0) 编辑
摘要:All good things come to an end. The concept of "done" plays a large part in our pattern and asynchronous code in general. We have to be able to handle 阅读全文
posted @ 2020-10-24 19:39 Zhentiw 阅读(113) 评论(0) 推荐(0) 编辑
摘要:The patterns we've established can also work well with plain old Objects and Arrays. We just have to capture the behavior of accessing those values in 阅读全文
posted @ 2020-10-24 15:49 Zhentiw 阅读(82) 评论(0) 推荐(0) 编辑
摘要:Functions returning functions returning functions can begin to look a bit unwieldy. The arrow function has helped the syntax a lot, but maybe using a 阅读全文
posted @ 2020-10-24 15:43 Zhentiw 阅读(118) 评论(0) 推荐(0) 编辑
摘要:Functions returning functions returning functions can begin to look a bit unwieldy. The arrow function has helped the syntax a lot, but maybe using a 阅读全文
posted @ 2020-10-24 15:35 Zhentiw 阅读(131) 评论(0) 推荐(0) 编辑
摘要:Remeber: each broadcast return a cancel function let createTimeout = (time) => (listener) => { let id = setTimeout(listener, time) return () => { clea 阅读全文
posted @ 2020-10-24 15:29 Zhentiw 阅读(152) 评论(0) 推荐(0) 编辑
摘要:import { compose } from "ramda"; let input = document.getElementById("input"); let inputBroadcaster = (listener) => { input.addEventListener("input", 阅读全文
posted @ 2020-09-30 18:32 Zhentiw 阅读(165) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示