首页 > Web开发 > 详细

[RxJS] Creation operator: of()

时间:2016-04-11 07:04:07      阅读:269      评论:0      收藏:0      [点我收藏+]

RxJS is a lot about the so-called "operators". We will learn most of the important operators, one by one. In this lesson, we will see our first creation operator: of().

 

var foo = Rx.Observable.of(42, 100, 200);

// var bar = Rx.Observable.create(function (observer) {
//   observer.next(42);
//   observer.next(100);
//   observer.next(200);
//   observer.complete();
// });

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

/*
"next 42"
"next 100"
"next 200"
"done"
*/

 

[RxJS] Creation operator: of()

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

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