随笔分类 -  Compose

1 2 3 4 5 ··· 7 下一页
摘要:function observe(obj) { for (const key in obj) { let internalValue = obj[key]; const funs = new Set() Object.defineProperty(obj, key, { configurable: 阅读全文
posted @ 2024-09-24 01:21 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:https://www.npmjs.com/package/ses Lockdown The lockdown() function also tames some objects including regular expressions, locale methods, and errors. 阅读全文
posted @ 2023-11-08 03:31 Zhentiw 阅读(6) 评论(0) 推荐(0) 编辑
摘要:Concurrency + Channel (CSP): Concurrency is a way to run operation in isolated thread, a way to better utilize the CPU resources and handle multi simu 阅读全文
posted @ 2023-10-31 15:10 Zhentiw 阅读(3) 评论(0) 推荐(0) 编辑
摘要:function getData(d) { setTimeout(() => { if (typeof d "number") { run.next(d/2) } else { run.next(d) } }, 500) } function* gen() { var x = 1 + (yield 阅读全文
posted @ 2023-10-26 14:43 Zhentiw 阅读(1) 评论(0) 推荐(0) 编辑
摘要:Thunks Sync thunk: A blocker of code which has everything ready and can return the value directly. function add(x, y) { return x + y } const thunk = f 阅读全文
posted @ 2023-10-18 14:52 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:An example of callback implemnetation for handling async flow: function fakeAjax(url, cb) { var fake_responses = { file1: "The first text", file2: "Th 阅读全文
posted @ 2023-10-17 15:03 Zhentiw 阅读(9) 评论(0) 推荐(0) 编辑
摘要:1. Basic version of signals We have a basic version of signal: const stack = [] export function createSignal(value) { const subscribers = new Set(); c 阅读全文
posted @ 2023-10-06 15:07 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:Implement two functions of Signals createSignal: return a tuple with read function and wrtie function createEffect: accept a function which will be ex 阅读全文
posted @ 2023-10-05 16:16 Zhentiw 阅读(3) 评论(0) 推荐(0) 编辑
摘要:PubSub is one of the most foundational patterns for reactivity. Firing an event out with publish() allows anyone to listen to that event subscribe() a 阅读全文
posted @ 2023-10-04 02:19 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:Requirements: function strBuilder(str) { return strBuilder; // TODO } var hello = strBuilder("Hello, "); var kyle = hello("Kyle"); var susan = hello(" 阅读全文
posted @ 2022-08-03 19:56 Zhentiw 阅读(22) 评论(0) 推荐(0) 编辑
摘要:function f(...args) { return args; } function flip(fn) { return function flipped (arg1, arg2, ...args) { return fn(arg2, arg1, ...args) } } let z = fl 阅读全文
posted @ 2022-07-31 16:45 Zhentiw 阅读(19) 评论(0) 推荐(0) 编辑
摘要:New broadcaster: compose: export let combine = (broadcaster1, broadcaster2) => listener => { let value1; let value2; let cancel1 = broadcaster1(value 阅读全文
posted @ 2020-12-17 15:49 Zhentiw 阅读(103) 评论(0) 推荐(0) 编辑
摘要:To build out our word game, we will have to be able to share the word across a few places. This means we have to set up a broadcaster that will push t 阅读全文
posted @ 2020-12-10 17:00 Zhentiw 阅读(116) 评论(0) 推荐(0) 编辑
摘要:Caches exist to make things faster (at the expense of taking up more memory and possibly outdated results). Our live search is a great use case for im 阅读全文
posted @ 2020-12-09 15:40 Zhentiw 阅读(90) 评论(0) 推荐(0) 编辑
摘要:In previous post, we check how to use ifElse to branch out the logic: https://www.cnblogs.com/Answer1215/p/14093562.html let inputToBooks = pipe( wait 阅读全文
posted @ 2020-12-08 22:28 Zhentiw 阅读(108) 评论(0) 推荐(0) 编辑
摘要:So far, we've used filter to prevent values when a condition is met. Sometimes you want two different behaviors based on a condition which is where yo 阅读全文
posted @ 2020-12-06 18:05 Zhentiw 阅读(147) 评论(0) 推荐(0) 编辑
摘要:export let mapError = transform => broadcaster => listener => { return broadcaster((value) => { if (value instanceof Error) { listener(transform(value 阅读全文
posted @ 2020-11-26 03:15 Zhentiw 阅读(69) 评论(0) 推荐(0) 编辑
摘要:You often want to ignore values until the user performs a certain action. This lesson walks through setting up an allowWhen broadcaster that will only 阅读全文
posted @ 2020-11-24 21:58 Zhentiw 阅读(129) 评论(0) 推荐(0) 编辑
摘要:To display a sequence of values in React, we can use our mapSequence operator, wrap it around a broadcaster, then pass that new broadcaster into our u 阅读全文
posted @ 2020-11-19 01:46 Zhentiw 阅读(113) 评论(0) 推荐(0) 编辑
摘要:Instead of always combining useState and useEffect, when can create a utility useBroadcaster hook which allows us to pass in a broadcaster. export let 阅读全文
posted @ 2020-11-17 22:30 Zhentiw 阅读(125) 评论(0) 推荐(0) 编辑

1 2 3 4 5 ··· 7 下一页
点击右上角即可分享
微信分享提示