[RxJS] Creation operators: fromEventPattern, fromEvent
Besides converting arrays and promises to Observables, we can also convert other structures to Observables. This lesson teaches how we can convert any addEventHandler/removeEventHandler API to Observables.
var foo = Rx.Observable.fromEvent(document, 'click'); foo.subscribe(function (x) {
console.log('next ' + x);
}, function (err) {
console.log('error ' + err);
}, function () {
console.log('done');
});
fromEventPattern(addEventHandler, removeEventHandler): take two functions
function addEventHandler(handler){
document.addEventListener('click', handler)
} function removeEventHandler(handler){
document.removeEventListener('click', handler)
} var foo = Rx.Observable.fromEventPattern(addEventHandler, removeEventHandler); foo.subscribe(function (x) {
console.log('next ' + x);
}, function (err) {
console.log('error ' + err);
}, function () {
console.log('done');
});
[RxJS] Creation operators: fromEventPattern, fromEvent的更多相关文章
- [RxJS] Creation operators: interval and timer
It is quite common to need an Observable that ticks periodically, for instance every second or every ...
- [RxJS] Creation operators: empty, never, throw
This lesson introduces operators empty(), never(), and throw(), which despite being plain and void o ...
- [RxJS] Creation operators: from, fromArray, fromPromise
The of() operator essentially converted a list of arguments to an Observable. Since arrays are often ...
- [RxJS] Creation operator: of()
RxJS is a lot about the so-called "operators". We will learn most of the important operato ...
- [RxJS] Creation operator: create()
We have been using Observable.create() a lot in previous lessons, so let's take a closer look how do ...
- Rxjs常用operators
本文使用的是angular6内置的rxjs,版本号为6.3.3 concat 通过顺序地发出多个 Observables 的值将它们连接起来,一个接一个的. 参数: 名称 类型 属性 描述 other ...
- [RxJS] Transformation operators: debounce and debounceTime
Debounce and debounceTime operators are similar to delayWhen and delay, with the difference that the ...
- [RxJS] Transformation operators: delay and delayWhen
This lessons teaches about delay and delayWhen: simple operators that time shift. delay(number | dat ...
- [RxJS] Filtering operators: skipWhile and skipUntil
After takeUntil() and takeWhile() function, let's have a look on skipWhile() and skilUntil() functio ...
随机推荐
- L-value 和 R-value.
An L-value is something that can appear on the left side of an equal sign, An R-value is something t ...
- tableView Crash
转自:http://blog.csdn.net/hamasn/article/details/8613593 Assertion failure in -[UITableView _configure ...
- Android放大镜的实现
package chroya.demo.magnifier; import android.content.Context; import android.graphics.Bitmap; impor ...
- 模块化的JavaScript开发的优势在哪里
如今模块化的 JavaScript 的开发越来越火热,无论是模块加载器还是优秀的 JavaScript 模块,都是层出不穷.既然这么火,肯定是有存在的理由,肯定是解决了某些实际问题.很多没接触过模块化 ...
- 安装 vsftp
1.yum安装 vsftp yum list vsftpd yum install vsftpd 2.配置 vsftp 将root注释掉 vi /etc/vsftpd/ftpusers 将root注释 ...
- (转载)图解Linux系统的系统架构
我以下图为基础,说明Linux的架构(architecture).(该图参考<Advanced Programming in Unix Environment>) 最内层是硬件,最外层是用 ...
- bootstrap导航条
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>我的 ...
- 在iframe里调用parent.func()引出的js函数运行在它们被定义的作用域里,而不是它们被执行的作用域里
有个document里定义了一个函数func(),同时在document里嵌入了一个iframe,在这个iframe里调用父窗口的方法:parent.func(),本来我以为这个函数的运行环境是在这个 ...
- 数据结构 --- 线性表学习(php模拟)
线性表:零个或多个数据元素的有限序列(注:以下都是用的整型数据模拟) 一 顺序存储结构(用一段地址连续的存储单元一次存储线性表的数据元素) 1.1 三个属性:存储空间的起始位置:最大存储容量:当前长度 ...
- Delphi-CompareStr 函数
函数名称 CompareStr 所在单元 System.SysUtils 函数原型 function CompareStr(const S1, S2: string): Integer; 函数功能 比 ...