[RxJS] Utility operator: do
2016-05-24 20:45
453 查看
We just saw map which is a transformation operator. There are a couple of categories of operators, such as filtering, combination, flattening, etc. One of these categories is the utility operators. The most important utility operator is
do, useful for debugging.
var foo = Rx.Observable.interval(200).take(4); /* foo: ---0---1---2---3--... do(x => console.log('before ' + x)) ---0---1---2---3--... map(x => x * 2) ---0---2---4---6--... do(x => console.log('after ' + x)) ---0---2---4---6--... */ var bar = foo .do(x => console.log('before ' + x)) .map(x => x * 2) .do(x => console.log('after ' + x)); bar.subscribe( function (x) { console.log('next ' + x); }, function (err) { console.log('error ' + err); }, function () { console.log('done'); }, );
相关文章推荐
- [RxJS] Transformation operator: map and mapTo
- js cookie 存储封装
- 使用JavaScript代码为博客园个人博客页面自动添置目录
- 10段代码打通js学习的任督二脉
- jsbridage框架
- javascript面向对象(转)
- js中的ajax的运用
- 异步请求后台json传回前台406
- JSON数据处理及与echarts结合使用时所需要的问题
- js中encode、decode的应用说明
- Javascript必知必会技术交流提纲
- javascript之DOM编程设置节点插入节点
- javascript之DOM编程设置节点插入节点
- 工具类系列-JackJsonStringTrimParser
- JavaScript的bom对象
- js显示鼠标坐标
- javascript之DOM编程根据属性找标签练习
- javascript之DOM编程根据属性找标签练习
- javascript之DOM编程通过html元素的标签属性找节点
- javascript之DOM编程通过html元素的标签属性找节点