当前位置:网站首页>rxjs Observable 自定义 Operator 的开发技巧
rxjs Observable 自定义 Operator 的开发技巧
2022-07-02 10:11:00 【InfoQ】
import { interval, of } from 'rxjs';
function fancyOperator(source) {
return source;
}
interval(1000)
.pipe(fancyOperator)
.subscribe((value) => console.log(value));



import { interval, Observable } from 'rxjs';
function fancyOperator(source) {
return Observable.create((observer) => {
observer.next('Jerry');
observer.complete();
});
}
interval(1000)
.pipe(fancyOperator)
.subscribe((value) => console.log(value));

import { fromEvent, interval, Observable } from 'rxjs';
import { filter } from 'rxjs/operators';
function filterKey(key) {
return filter((event: KeyboardEvent) => event.key === key);
}
fromEvent(document, 'keyup')
.pipe(filterKey('Enter'))
.subscribe(
(data) => console.log(data) // KeyboardEvent
);










边栏推荐
- Fundamentals of machine learning (II) -- division of training set and test set
- The second anniversary of the three winged bird: the wings are getting richer and the take-off is just around the corner
- I did it with two lines of code. As a result, my sister had a more ingenious way
- ADB basic commands
- What are the classifications of SSL certificates? How to choose the appropriate SSL certificate?
- Unity SKFramework框架(十五)、Singleton 单例
- 挥发性有机物TVOC、VOC、VOCS气体检测+解决方案
- Unity skframework framework (XX), VFX lab special effects library
- 诚邀青年创作者,一起在元宇宙里与投资人、创业者交流人生如何做选择……...
- [cloud native database] what to do when encountering slow SQL (Part 1)?
猜你喜欢
题解:《压缩技术》(原版、续集版)
Don't spend money, spend an hour to build your own blog website
Daily practice of C language --- monkeys divide peaches
OpenApi-Generator:简化RESTful API开发流程
Unity skframework framework (XIV), extension extension function
Independent and controllable 3D cloud CAD: crowncad enables innovative design of enterprises
Memory management 01 - link script
记忆函数的性能优化
题解:《你的飞碟在这儿》、《哥德巴赫猜想》
Embedded software development
随机推荐
【蓝桥杯选拔赛真题43】Scratch航天飞行 少儿编程scratch蓝桥杯选拔赛真题讲解
【OpenGL】笔记二十九、高级光照(镜面高光)
Don't spend money, spend an hour to build your own blog website
ADB basic commands
Lucky numbers in the [leetcode daily question] matrix
D如何检查null
Unity SKFramework框架(十六)、Package Manager 开发工具包管理器
基于ssm+jsp框架实现的学生选课信息管理系统【源码+数据库】
Detailed collection of common MySQL commands
诚邀青年创作者,一起在元宇宙里与投资人、创业者交流人生如何做选择……...
Gee learning notes 2
三翼鸟两周年:羽翼渐丰,腾飞指日可待
[true topic of the Blue Bridge Cup trials 43] scratch space flight children's programming explanation of the true topic of the Blue Bridge Cup trials
P3807 [template] Lucas theorem /lucas theorem
Download files and preview pictures
Everyone wants to eat a broken buffet. It's almost cold
口袋奇兵点评
OpenFOAM:lduMatrix&lduAddressing
Security RememberMe原理分析
Unity SKFramework框架(二十)、VFX Lab 特效库