随笔分类 - 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
阅读全文
摘要: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
阅读全文
摘要:In previous post, we have follow code: const delayMessage = (message) => hardCode(message)(createTimeout(1000)); const sequence = (...broadcasters) =>
阅读全文
摘要:Many scenarios involve one task happening after another has completed. This lesson walks you through setting up "steps" which trigger one after anothe
阅读全文
摘要:Asynchronous code often uses conditions to determine when a block of code should finish running. This lesson walks through writing a doneIf operator w
阅读全文
摘要:Apps often have scenarios where one event controls another. In operators, this requires passing one broadcaster in and using it to control another bro
阅读全文
摘要:After a broadcaster is "done", starting it up again requires calling the broadcaster with the same listener. This creates a kind of "async recursion"
阅读全文
摘要:Controlling when a broadcaster starts and stops gives you complete control over your broadcasters. This let's you hook multiple pieces of UI together
阅读全文
摘要:document.getElementById("app").innerHTML = ` <h1>Hello Parcel!</h1> <div> <button id="plus">+</button> <button id="mius">-</button> </div> `; const ad
阅读全文
摘要:import { curry, compose, toUpper, pipe } from 'ramda'; // #region listeners const _log = (value) => console.log(value); // #endregion // #region broad
阅读全文
摘要:Buffers give you chance to gather values together until your ready to work with them. This pattern can be used for calculations, string manipulations,
阅读全文
摘要:In our previous code, we have seen this partten for operators: // #region operators const concat = curry((broadcaster, listener) => { let string = '';
阅读全文
摘要: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
阅读全文
摘要:import { curry } from 'ramda'; // #region listeners const _log = (value) => console.log(value); // #endregion // #region broadcasters const done = Sym
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Remeber: each broadcast return a cancel function let createTimeout = (time) => (listener) => { let id = setTimeout(listener, time) return () => { clea
阅读全文
摘要:import { compose } from "ramda"; let input = document.getElementById("input"); let inputBroadcaster = (listener) => { input.addEventListener("input",
阅读全文