1 Star 0 Fork 2

hokhyk / learning-rxjs

forked from 燕云长风 / learn-rxjs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
distinct.ts 546 Bytes
一键复制 编辑 原始数据 按行查看 历史
燕云长风 提交于 2019-05-30 19:42 . add filter,transform,merge operators
import {fromEvent} from 'rxjs'
import { pluck , distinct} from 'rxjs/operators';
//过滤类操作符 distinct 让流里无重复数据,类似es6 set功能
//对无尽序列使用distinct要小心,因为对整个序列做监控,内存消耗大
// distinct
{
const width = document.getElementById("width");
const width$ = fromEvent(width,'keyup').pipe(
pluck('target','value'),
distinct()
);
width$.subscribe(
value => console.log(value)
)
// 输入重复的数据,不做第二次输出
}
TypeScript
1
https://gitee.com/hokhyk/learning-rxjs.git
git@gitee.com:hokhyk/learning-rxjs.git
hokhyk
learning-rxjs
learning-rxjs
master

搜索帮助