[Cycle.js] Customizing effects from the main function
JS The from Function main cycle Effects
2023-09-14 08:59:20 时间
How can we show one string on the DOM, and a completely different string on Console log? This lesson shows how we can make our main function return multiple Observables, each one targeted at a different type of effect.
// Logic (functional) function main() { return { DOM: Rx.Observable.timer(0, 1000).map( i => `timer is ${i}`), Log: Rx.Observable.timer(0, 1000).map(i => 2*i ) }; i} function DOMEffect(text$) { text$.subscribe(text => { const container = document.querySelector('#app'); container.textContent = text; }); } function consoleLogEffect(msg$) { msg$.subscribe(msg => console.log(msg)); } const sinks = main(); DOMEffect(sinks.DOM); consoleLogEffect(sinks.Log);
相关文章
- SqlBulkCopy – The given value of type String from the data source cannot be converted to type
- The method assertEquals(double, double) from the type Assert is deprecated
- 手撕常见JS面试题
- JS面试题-js新增基本数据类型BigInt
- js中截取字符串的三个方法 substring()、substr()、slice()
- 【JS 逆向百例】猿人学系列 web 比赛第二题:js 混淆 - 动态 cookie,详细剖析
- 快速部署Vue.js前端项目
- JS 按自定义格式 拼接二进制串 解析二进制串
- ORA-28074: The “string” field of the redaction parameters is not valid. ORACLE 报错 故障修复 远程处理
- ORA-48487: The internal predicate string exceeds the maximum length [string] ORACLE 报错 故障修复 远程处理
- ORA-48490: The field number exceeds the maximum number [string] ORACLE 报错 故障修复 远程处理
- ORA-53410: The attribute string does not conform to the VM rule. ORACLE 报错 故障修复 远程处理
- JS把指定日期转换为几秒前、几小时前等格式详解编程语言
- js使用正则表达式判断ip地址详解编程语言
- 「Linux 录屏软件下载」功能强大,操作简单!(Note: The translation of the title can be read as Linux Screen Recording Software Download: Powerful Functionality Simple Operation! (linux录屏软件下载)
- Exploring the versatility of Linux: The significance of the var directory(linux系统var)
- Exploring the Power of Linux: The Versatility and Potential of Aud Files(linux系统aud文件)
- js实现的仿Photoshop鼠标滚轮控制输入框取值(修正兼容Chrome)
- 基于jquery封装的一个js分页
- js获取坐标通过JS得到当前焦点(鼠标)的坐标属性