[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 ...
随机推荐
- php中foreach()函数与Array数组经典案例讲解
//php中foreach()函数与Array数组经典案例讲解 function getVal($v) { return $v; //可以加任意检查代码,列入要求$v必须是数字,或过滤非法字符串等.} ...
- File System Shell
Overview appendToFile cat chgrp chmod chown copyFromLocal copyToLocal count cp du dus expunge get ge ...
- servlet跳转jsp
ackage com.monkey.servlet; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; im ...
- chrome:// 的秘密!!一些有用的命令!
chrome:// .......命令 集结 Chrome 有很多的特性在界面菜单中是没有体现的,可以通过 chrome:// 命令来访问 我搜集了下面这些!!!当然也是在网上找的!有的我自己也不知道 ...
- oracle 自动增长
在SQLSERVER和MYSQL里面自动增长字段直接设置就可以.在ORACLE里面就复杂多了.特别是我这样的初学者,不过网络是最好的老师,看了很多相关介绍,本人使用的是使用触发器.具体如下: 首先要创 ...
- tomcat发布静态网页
- iOS 宏定义_16进制色值转化为RGB返回UIColor类型对象
// 十六进制颜色 #define COLOR_WITH_HEX(hexValue) [UIColor colorWithRed:((float)((hexValue & 0xFF0000) ...
- Asterix and Obelix
uva10246:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&am ...
- centos 6.5安装esx sdk
1. RHEL 6.3 64 bit yum install e2fsprogs-devel libuuid-devel yum install glibc.i686 yum install perl ...
- 【HDOJ】4109 Instrction Arrangement
差分约束. /* 4109 */ #include <iostream> #include <queue> #include <vector> #include & ...