[RxJS] Split an RxJS observable with window
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));
[RxJS] Split an RxJS observable with window的更多相关文章
- [RxJS] Split an RxJS observable conditionally with windowToggle
There are variants of the window operator that allow you to split RxJS observables in different ways ...
- [RxJS] Split an RxJS Observable into groups with groupBy
groupBy() is another RxJS operator to create higher order observables. In this lesson we will learn ...
- [RxJS] Stopping a shared observable execution
ConnectableObservable has the connect() method to conveniently dictate the start of the shared execu ...
- [RxJS] Introduction to RxJS Marble Testing
Marble testing is an expressive way to test observables by utilizing marble diagrams. This lesson wi ...
- [AngularJS + RxJS] Search with RxJS
When doing search function, you always need to consider about the concurrent requests. AEvent ----(6 ...
- Angular快速学习笔记(4) -- Observable与RxJS
介绍RxJS前,先介绍Observable 可观察对象(Observable) 可观察对象支持在应用中的发布者和订阅者之间传递消息. 可观察对象可以发送多个任意类型的值 -- 字面量.消息.事件. 基 ...
- RxJS——可观察的对象(Observable)
可观察的(Observable) 可观察集合(Observables)是多值懒推送集合.它们填补了下面表格的空白: SINGLE MULTIPLE Pull Function Iterator Pus ...
- rxjs简单入门
rxjs全名Reactive Extensions for JavaScript,Javascript的响应式扩展, 响应式的思路是把随时间不断变化的数据.状态.事件等等转成可被观察的序列(Obser ...
- RxJS v6 学习指南
为什么要使用 RxJS RxJS 是一套处理异步编程的 API,那么我将从异步讲起. 前端编程中的异步有:事件(event).AJAX.动画(animation).定时器(timer). 异步常见的问 ...
随机推荐
- RFID的基本组织构成
RFID技术由3大组件构成, 包括: 阅读器.天线.标签三大组件. 阅读器 为RFID系统最重要也是最复杂的一个组件.因其工作模式一般是主动向标签询问标识信息, 所以有时又被称为询问器(Interro ...
- [MySQL 5.1 体验]MySQL 实例管理器 mysqlmanager 初试
原贴:http://imysql.cn/node/313 [MySQL 5.1 体验]MySQL 实例管理器 mysqlmanager 初试 周二, 2007/06/19 - 22:10 - yejr ...
- A题之拼音转数字
输入是一个仅仅包括拼音的字符串,请输出相应的数字序列.转换关系例如以下: 描写叙述: 拼音 yi er san si wu liu qi ba jiu 阿拉伯数字 1 2 3 4 5 6 ...
- 1.1 Introduction中 Consumers官网剖析(博主推荐)
不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Consumers 消费者(Consumers) Consumers label t ...
- Android前后端交互细节--Json转化为对象的原理
移动互联网用户基数越来越大,除了一些工具类(指南针.手电筒等)的应用,绝大部分APP都需要与后端进行交互. 交互的数据格式有JSON.XML等,由于JSON具有语法简单.占用空间小等优势,基本所有的公 ...
- ASP.NET MVC案例教程(基于ASP.NET MVC beta)——第二篇:第一个页面
摘要 本文首先一步一步完成Demo的第一个页面——首页.然后根据实现过程,说明一下其中用到的与ASP.NET MVC相关的概念与原理. 让第一个页面跑起来 现在,我们来实现公告系统 ...
- Vue自定义组件
- (转)linux的一个find命令配合rm删除某天前的文件
转自:http://www.cnblogs.com/mingforyou/p/3930624.html 语句写法:find 对应目录 -mtime +天数 -name "文件名" ...
- django-rest-framework框架 第二篇 之Mixin扩展类
Mixin扩展类 ['列表操作','过滤','搜索','排序'] <一>:<1>创建项目: 配置 urls 主路由 配置model文件(举个例子,就以book为模 ...
- mysql 配置,还得多看看~
http://blog.chinaunix.net/uid-20639775-id-154429.html