[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 ...
随机推荐
- iOS:等待控件
定义: @interface ViewController () { UIActivityIndicatorView *testActivityIndicator; } 实例化,开始旋转: -(voi ...
- SQLSERVER 中GO的作用详解
具体不废话了,请看下文详解. ? 1 2 3 4 5 6 7 8 9 10 use db_CSharp go select *, 备注=case when Grade>=90 then ' ...
- 利用jquery操作Radio方法小结
用Radio来实现用户的选择效果,在项目中积累了一些利用JQUERY来操作Radio的方法,这里与大家分享下 在开发中经常会用到Radio来实现用户的选择效果,我在项目中积累了一些利用JQUERY来操 ...
- Gems
zoj2332:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2332 题意:这一道题的题意,我看了很久,也没有看明白,最终 ...
- Android 设置隐式意图
AndroidManifest.xml对于被调用的activity: <activity android:name="com.wuyou.twoactivity.OtherActivi ...
- 定制ckeditor的菜单
修改配置文件config.js来定制cheditor的菜单,需要以下步骤: 1.找到ckeditor安装目录的config.js文件 2.记下要使用的功能名,以下的"-"代表分隔符 ...
- C++ Prime:sizeof运算符
sizeof运算符的结果部分地依赖于其作用的类型: 对char或者类型为char的表达式执行sizeof运算结果得1: 对引用类型执行sizeof运算得到被引用对象所占空间的大小: 对指针执行size ...
- BZOJ1617: [Usaco2008 Mar]River Crossing渡河问题
1617: [Usaco2008 Mar]River Crossing渡河问题 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 654 Solved: 4 ...
- 【转】VC++ MFC 常用技巧(一)
原文网址:http://www.lewensky.cn/read.php/106.htm (-). 下面是常见的Afx全局函数: AfxFormatString1:类似printf一般地将字符串格式化 ...
- (转载)MySQL关键字GROUP BY的使用
例子: mysql> select * from employee; +------+------+-------+------+-------+----------+ | num | d_id ...