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

[RxJS] Creation operator: of()

时间:2016-04-11 07:06:03      阅读:151      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!