RxJS
處理數(shù)據(jù)流

管道
1 在項(xiàng)目中使用
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/map';
title = 'aspp';
using(){
// 定義數(shù)據(jù)源
let onSubscribe = (observer)=>{
observer.next(1);
observer.next(2);
observer.next(3);
}
// 數(shù)據(jù)源
const source$ = Observable.create(onSubscribe);
// 對(duì)每一個(gè)數(shù)據(jù),進(jìn)行操作
source$.map((item)=>{
return item +1;
}).subscribe((res)=>{console.log(res)});
}
constructor(){
this.using();
}
運(yùn)行效果:

image.png