美文网首页
☕️RxJS -- 定义

☕️RxJS -- 定义

作者: YI_YI_ | 来源:发表于2020-02-14 11:38 被阅读0次

RxJS

处理数据流


管道

1 在项目中使用

import {Observable} from 'rxjs/Observable';
import  'rxjs/add/operator/map';

 title = 'aspp';
  using(){
    // 定义数据源
    let onSubscribe = (observer)=>{
      observer.next(1);
      observer.next(2);
      observer.next(3);
    
    }
    // 数据源
      const source$ = Observable.create(onSubscribe);
    // 对每一个数据,进行操作
      source$.map((item)=>{
        return item +1;
      }).subscribe((res)=>{console.log(res)});
   }
   constructor(){
     this.using();
   }


运行效果:


image.png

2 数据操作符

相关文章

网友评论

      本文标题:☕️RxJS -- 定义

      本文链接:https://www.haomeiwen.com/subject/bwvcfhtx.html