[Angular] Upgrading to RxJS v6
2024-09-06 03:21:49
This is just a learning blog post, check out the talk.
1. Custom pipeable operators:
Custom pipeable operator is just a high order function which return an observable.
const pow = (p: number) => (source: Observable<number>) => source.pipe(map(n => n ** p )) source$.pipe(
filter(x => x > ),
pow()
).subscribe(x => console.log(x))
2. Error handling: Throw error asynclly:
badSource$.subscribe(nextFn. handlerError, completeFn)
3. Simpler import:
import {interval, of} from 'rxjs';
import {filter, mergeMap, scan} from 'rxjs/operators'; interval().pipe(
filter(x => x % === ),
mergeMap(x => of(x + , x + , x + m)),
scan((s, x) => s +x, )
).subscribe(x => console.log(x));
4. New operator: throwIfEmpty
const mustClick$ = buttonClick$.pipe(
takeUntil(this.viewResize$),
throwIfEmpty(
() => new Error('user did not click before resize')
),
);
5. If you want to migration to rxjs v6:
6. Update you code automatically:
最新文章
- Angular.js中使用$watch监听模型变化
- js对文本框特殊字符串过滤
- JavaScript基础--面向对象三大特性(八):继承封装多态
- docker-py的配置与使用
- [HIHO1174]拓扑排序&#183;一(拓扑排序)
- 更改Activity亮度
- NSFileHandle 和 NSFileManager的一些用法
- 用C#来查看电脑硬件和系统信息
- MediaInfo源代码分析 2:API函数
- .net core4
- Shortest Prefixes
- Error copying image in the datastore: Not allowed to copy image file
- mongodb 复制集
- webapi框架搭建-创建项目(二)-以iis为部署环境的配置
- 关于CS1061报错(XX不包含XXX的定义,并且找不到类型为XX的第一个参.....)的一种可能的解决的办法
- Visual Studio Code-批量在文末添加文本字段
- python入门学习:6.用户输入和while循环
- redis底层设计(五)——内部运作机制
- ES7/8新特性学习随笔
- SSE,MSE,RMSE,R-square指标讲解