[RxJS] Split an RxJS observable with window
with an window Rxjs split Observable
2023-09-14 09:00:52 时间
Mapping the values of an observable to many inner observables is not the only way to create a higher order observable. RxJS also has operators that take a first order observable and return a higher order Observable. In this lesson we will learn about window, an operator to split an observable.
'window' main task is to split observable to multi inner observables. That allows me do something useful to individual inner observable, such as 'scan' & 'count'.
const clickObservable = Rx.Observable.fromEvent(document, 'click'); const clockObservable = Rx.Observable.interval(1000); const resultObservable = clockObservable .window(clickObservable) .map(obs => obs.count()) .switch(); /* --0---1---2---3---4---5---6---7---8| --------c-----------c---c----------- window +-------+-----------+---+----------+ \ \ \ \ \ --0---1-|-2---3---4-|-5-|-6---7---8| .map(o => o.count()) --------+-----------+---+---------+ \ \ \ \ -------2|----------3|--1|--------3| switch --------2-----------3---1---------3 */ resultObservable .subscribe(x => console.log(x));
相关文章
- GitHub推送报错:You‘re using an RSA key with SHA-1, which is no longer allowed
- 【错误记录】Android Studio 向 GitHub 提交代码报错 ( Push failed: Failed with error: Could not read | 使用命令行提交代码 )
- ORA-22335: The client cannot work with an altered type ORACLE 报错 故障修复 远程处理
- ORA-29809: cannot drop an operator with dependent objects ORACLE 报错 故障修复 远程处理
- ORA-32487: unsupported join in recursive WITH query ORACLE 报错 故障修复 远程处理
- ORA-41617: action preference name “string” collides with an event attribute name ORACLE 报错 故障修复 远程处理
- MySQL Error number: 3112; Symbol: ER_CANT_USE_AUTO_POSITION_WITH_GTID_MODE_OFF; SQLSTATE: HY000 报错 故障修复 远程处理
- ORA-64143: Can only share an existing XMLIndex table with an XMLTYPE column. ORACLE 报错 故障修复 远程处理
- ORA-00491: RMS0 process terminated with error ORACLE 报错 故障修复 远程处理
- MySQL Error number: MY-011529; Symbol: ER_GRP_RPL_MEMBER_CFG_INCOMPATIBLE_WITH_GRP_CFG; SQLSTATE: HY000 报错 故障修复 远程处理
- ORA-12831: Must COMMIT or ROLLBACK after executing INSERT with APPEND hint ORACLE 报错 故障修复 远程处理
- ORA-13719: Imported AWR snapshots are from a database with an incompatible character set. ORACLE 报错 故障修复 远程处理
- Java之创建对象>3.Enforce the singleton property with a private constructor or an enum type详解编程语言
- Get Well Acquainted with Linux: A Comprehensive Note(linuxnote)
- 语句掌握Oracle中用WITH语句的利用技巧(oracle的with)
- Making Linux Easier with XCB: An Overview(xcblinux)
- Exploring the World of Linux with Ease: A Guide to Using Aoyou(遨游forlinux)
- Transforming Your Linux Login Experience with Simple User Modifications(linux改变登录用户)
- Efficient File Searching with the find Command in Linux(linux下find命令)
- Streamlining HR Operations with Oracle: A Comprehensive Guide(oraclehr)
- 从Oracle中挖掘洞见坚实的With表(oracle with表)