[RxJS] Learn How To Use RxJS 5.5 Beta 2
Posted Answer1215
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[RxJS] Learn How To Use RxJS 5.5 Beta 2相关的知识,希望对你有一定的参考价值。
The main changes is about how you import rxjs opreators from now on. And introduce lettable opreator.
import { range } from ‘rxjs/observable/range‘; import { map, filter, scan } from ‘rxjs/operators‘; const source$ = range(0, 10); source$.pipe( filter(x => x % 2 === 0), map(x => x + x), scan((acc, x) => acc + x, 0) ) .subscribe(x => console.log(x))
Build own opreator:
import { interval } from ‘rxjs/observable/interval‘; import { map, take, toArray } from ‘rxjs/operators‘; /** * an operator that takes every Nth value */ const takeEveryNth = (n: number) => <T>(source: Observable<T>) => new Observable(observer => { let count = 0; return source.subscribe({ next(x) { if (count++ % n === 0) observer.next(x); }, error(err) { observer.error(err); }, complete() { observer.complete(); } }) }); interval(1000).pipe( takeEveryNth(2), map(x => x + x), takeEveryNth(3), take(3), toArray() ) .subscribe(x => console.log(x)); // [0, 12, 24]
以上是关于[RxJS] Learn How To Use RxJS 5.5 Beta 2的主要内容,如果未能解决你的问题,请参考以下文章
Medical Mold - How To Use Different Blood Collection Needles
How to use the Custom Material node and create Metaballs 官方视频学习笔记
How to tune hyperparameters with Python and scikit-learn?