[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 ...
随机推荐
- c - 根据首字母判断星期几
#include <stdio.h> #include <ctype.h> /* 请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续判断第二个字母. */ ...
- Linux下svn命令switch用法
# svn info /data/www/49you/api.49you.com Path: /data/www/49you/api.49you.comURL: svn://192.168.10.81 ...
- c#求slope线性回归斜率
public class mySlope { // public List<double> Values { get; set; } public double SlopeResult { ...
- cas sso单点登录系列2:cas客户端和cas服务端交互原理动画图解,cas协议终极分析
转:http://blog.csdn.net/ae6623/article/details/8848107 1)PPT流程图:ppt下载:http://pan.baidu.com/s/1o7KIlom ...
- Hibernate 一对多双向关联Demo
以Classes[班级]和Student[学生]为例的Demo //Classes.java public class Classes implements Serializable { privat ...
- dbm数据库
所有版本的linux以及大多数的UNIX版本都随系统带有一个基本的.但却非常搞笑的数据存储历程集,他被称为dbm数据库.适用于存储比较静态的索引化数据库,即使用索引来存储可变长的数据结构,然后通过索引 ...
- Python list 常用操作
测试版本: python 2.7 获取第一个.最后一个元素 list1 = ["a", "b", "c"] len1 = len(list1 ...
- Spring4.0学习笔记(12) —— JDBCTemplate 操作数据库
整体配置 1.配置xml文件 <beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi ...
- c++builder向c#开发的webservice传递非数字参数
一.引用WebService地址 BCB6.0环境下,File-New-Other-WebService-WSDL Importer.然后手动写完整地址.如:“http://192.168.1.3:1 ...
- PS抠图神器:KNOCKOUT 2.0
从优设上转载~~太好用了,保存下来以备不时之需. 本人亲身实践~~先看使用成果~~哈哈~~ 原版图 : 抠过的图: 主要看飘逸的发丝~~~而且全程操作不超过5分钟!! 下载地址: http://vdi ...