[RxJS] Transformation operators: delay and delayWhen
This lessons teaches about delay and delayWhen: simple operators that time shift.
delay(number | date)
var foo = Rx.Observable.interval(500).take(5); /*
--0--1--2--3--4|
delay(1000)
-----0--1--2--3--4|
*/ // delay(1000)
var result = foo.delay(1000); result.subscribe(
function (x) { console.log('next ' + x); },
function (err) { console.log('error ' + err); },
function () { console.log('done'); },
);
var foo = Rx.Observable.interval(500).take(5); /*
--0--1--2--3--4|
delay(date)
-----0--1--2--3--4|
*/ var date = new Date(new Date().getTime() + 1000);
var result = foo.delay(date); result.subscribe(
function (x) { console.log('next ' + x); },
function (err) { console.log('error ' + err); },
function () { console.log('done'); },
);
delayWhen( function :Observable): accept a function which return an observable:
var foo = Rx.Observable.interval(500).take(5); /*
--0--1--2--3--4|
delayWhen(x => --------0--------...)
--------0--------1--------2--------3--------4|
*/ // delay(1000)
var result = foo.delayWhen(x =>
Rx.Observable.interval(x * 1000) // For each foo, it will delay 1000 * x, so '2' --> 2000, '3' ---> 3000
); result.subscribe(
function (x) { console.log('next ' + x); },
function (err) { console.log('error ' + err); },
function () { console.log('done'); },
);
[RxJS] Transformation operators: delay and delayWhen的更多相关文章
- [RxJS] Transformation operators: debounce and debounceTime
Debounce and debounceTime operators are similar to delayWhen and delay, with the difference that the ...
- [RxJS] Creation operators: interval and timer
It is quite common to need an Observable that ticks periodically, for instance every second or every ...
- Rxjs常用operators
本文使用的是angular6内置的rxjs,版本号为6.3.3 concat 通过顺序地发出多个 Observables 的值将它们连接起来,一个接一个的. 参数: 名称 类型 属性 描述 other ...
- [RxJS] Transformation operator: repeat
Operator repeat() is somewhat similar to retry(), but is not for handling operators. In this lesson ...
- [RxJS] Transformation operator: scan
All of the combination operators take two or more observables as input. These operators may also be ...
- [RxJS] Filtering operators: takeLast, last
Operators take(), skip(), and first() all refer to values emitted in the beginning of an Observable ...
- [RxJS] Filtering operators: take, first, skip
There are more operators in the filtering category besides filter(). This lesson will teach how take ...
- [RxJS] Creation operators: empty, never, throw
This lesson introduces operators empty(), never(), and throw(), which despite being plain and void o ...
- [RxJS] Filtering operators: distinct and distinctUntilChanged
Operator distinct() and its variants are an important type of Filtering operator. This lessons shows ...
随机推荐
- Java:对象的序列化
一.对象序列化机制 序列化机制允许将实现序列化的Java对象转换为字节序列,这些字节序列可以被保存在磁盘上或通过网络传输,以备以后重新恢复原来的对象: 序列化机制使得对象可以脱离程序的运行而独立存在: ...
- smarty模板引擎原理解析
//php 控制器文件 <?php//引入模板引擎文件include("20130304.php");$smarty =newTinySmarty();$qq_numbers ...
- TCP/IP笔记 应用层(3)——HTTP
1. URL URL(Uniform Resource Locator) 相当于一个文件名在网络范围的扩展. 1.1 格式 schema://host[:port#]/path/.../[?query ...
- Android 安全概述
1. 保密: 信息.文档加密.解密 2. 鉴别.认证:就像确认与我们打电话的确实是XXX,而不是骗子 3. 完整性:信息不能被篡改, 4. 不可否认性:确定信息有who产生,并且将来不能否认
- linux下date命令实现时间戳与日期的转换
1.查看指定时间的时间戳 查看当前时间 #date +%s 查看指定时间 #date -d 2008-01-01 +%s 1199116800 #date -d 20080101 ...
- linux之GDB常用命令汇总
查看gdb的版本号 (1)rpm -q gdb 会显示是否安装gdb及版本号 (2)gdb --version也可以 breakpoint b main; b 20; 设置断点 breakpoint ...
- 用三或四个个div标签实现工字效果
使用重构的方式制作出一个如下图的水平.垂直都居中,短边为50px,长边为150px的红色“工”字. a) 使用3个div完成 <!DOCTYPE html><html lang=&q ...
- 通过jquery获取后台传过来的值进行全选
注:funs是从action中传过来的list<Function> 其中属性中有其子对象list<role> 下面通过s标签遍历 ,也可以通过c标签遍历 jsp页面中: < ...
- 【产品体验】支付宝Alipay9.0
自己摸索中也要学习别人的分析,生命不息,学习不止~~ 支付宝9.0新界面如下图所示——Logo变了,上方突出了“附近”入口,下方新增了“商家”“朋友”两个一级tab,新增了亲情账户,财富界面进行了改 ...
- bzoj 2115: [Wc2011] Xor xor高斯消元
2115: [Wc2011] Xor Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 797 Solved: 375[Submit][Status] ...