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

[RxJS] Transformation operator: repeat

时间:2016-05-31 20:44:26      阅读:133      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!