首页 > Web开发 > 详细

[RxJS] Transformation operator: repeat

时间:2016-05-31 20:43:34      阅读:207      评论:0      收藏:0      [点我收藏+]

Operator repeat() is somewhat similar to retry(), but is not for handling operators. In this lesson we learn how repeat works.

 

var foo = Rx.Observable.interval(500)
  .zip(Rx.Observable.of(‘a‘,‘b‘,‘c‘,‘d‘), (x,y)=>y);

var bar = foo.map(x => x.toUpperCase());

/*
--a--b--c--d|     (foo)
map(toUpperCase)
--A--B--C--D|      (bar)
 repeat
--A--B--C--D--A--B--C--D--A--B--C--D|
*/

var result = bar.repeat(3);

result.subscribe(
  function (x) { console.log(‘next ‘ + x); },
  function (err) { console.log(‘error ‘ + err); },
  function () { console.log(‘done‘); },
);

 

[RxJS] Transformation operator: repeat

原文:http://www.cnblogs.com/Answer1215/p/5547185.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!