[RxJS] Filtering operator: filter
Posted Answer1215
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[RxJS] Filtering operator: filter相关的知识,希望对你有一定的参考价值。
This lesson introduces filter: an operator that allows us to let only certain events pass, while ignoring others.
var foo = Rx.Observable.interval(1000); /* --0--1--2--3--4--5--6--7- filter(x => x % 2 === 0) --0-----2-----4-----6---- */ var bar = foo.filter(x => x % 2 === 0); bar.subscribe( function (x) { console.log(‘next ‘ + x); }, function (err) { console.log(‘error ‘ + err); }, function () { console.log(‘done‘); }, );
以上是关于[RxJS] Filtering operator: filter的主要内容,如果未能解决你的问题,请参考以下文章
[RxJS] Filtering operators: throttle and throttleTime
[RxJS] Filtering operators: distinct and distinctUntilChanged
[RxJS] Filtering operator: single, race