您的位置:首页 > Web前端 > JavaScript

[RxJS] Creation operator: of()

2016-04-11 02:18 501 查看
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"
*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: