码迷,mamicode.com
首页 > Web开发 > 详细

[RxJS] Filtering operator: filter

时间:2016-05-25 16:36:34      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

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

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/5527518.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!