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(); 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));

最新文章

  1. Power BI官方视频(1) Power BI Desktop 7月份更新功能概述
  2. easyui datagrid的列编辑
  3. Lambda Grinding Miller From Zenith
  4. poj2299 二分思想
  5. PGsql解决时差24H
  6. sass教程
  7. 面向对象---final关键字
  8. js 抓取屏幕宽度设置字体大小 rem
  9. [angularjs] AngularJs 知识回顾
  10. pta寒假作业3
  11. android开发_ViewGroup(组视图)-- 五大布局
  12. zabbix-Get value from agent failed: cannot connect to [[127.0.0.1]:10050]: [111] Connection refused
  13. 网络基础 TCP/IP
  14. 登录MySQL提示ERROR 1045 (28000)错误解决方法
  15. 批量修改Java类文件中引入的package包路径
  16. 【期望DP】BZOJ3450- Tyvj1952 Easy
  17. hadoop中mapreduce的默认设置
  18. Android 显示意图和隐式意图的区别
  19. android黑科技系列——Android中新型安全防护策略
  20. Spark基本运行流程

热门文章

  1. java中goto语句
  2. HDU3689 Infinite monkey theorem 无限猴子(字符串DP+KMP)
  3. 四、Docker+Tomcat
  4. [MySQL 5.1 体验]MySQL 实例管理器 mysqlmanager 初试
  5. [Vue + TS] Using Route events inside Vue
  6. 使用Spring框架的好处
  7. mysql测试spring事务是否生效
  8. Android代码模拟物理、屏幕点击事件
  9. 洛谷 P1206 [USACO1.2]回文平方数 Palindromic Squares
  10. JAVA开发类似冒险岛的游戏Part1