zoukankan      html  css  js  c++  java
  • RXJS 系列 01

    每日前提

    1. 内容为学习后的自我总结。再次感谢博主的分享,附上原po链接: 原po链接

    宝珠图(Marble diagrams)

    用-来表达一小段时间,这些-串起就代表一个observable(表示时间序列)
    ----------------
    ---------------X	// Error happened
    ---------------|	// observerable completed
    
    Example one:
    var source = Rx.Observable.interval(1000);
    -----0-----1-----2-----3--...
    
    Example two:
    var source = Rx.Observable.of(1,2,3,4);
    (1234)|				// () means sync
    
    Example three:
    var source = Rx.Observable.interval(1000);
    var newest = source.map(x => x + 1); 
    source: -----0-----1-----2-----3--...
                map(x => x + 1)
    newest: -----1-----2-----3-----4--...
    
    Example Four:
    var source = Rx.Observable.interval(1000);
    var newest = source.map(x => x + 2); 
    
    newest.subscribe(console.log);
    // 2
    // 3
    // 4
    // 5..
    
    source: -----0-----1-----2-----3--...
                map(x => x + 1)
    newest: -----1-----2-----3-----4--...
    
    Example Five:
    var source = Rx.Observable.interval(1000);
    var newest = source.mapTo(2); 
    
    newest.subscribe(console.log);
    // 2
    // 2
    // 2
    // 2..
    source: -----0-----1-----2-----3--...
                    mapTo(2)
    newest: -----2-----2-----2-----2--...
    
    Example Six:
    var source = Rx.Observable.interval(1000);
    var newest = source.filter(x => x % 2 === 0); 
    
    newest.subscribe(console.log);
    // 0
    // 2
    // 4
    // 6..
    source: -----0-----1-----2-----3-----4-...
                filter(x => x % 2 === 0)
    newest: -----0-----------2-----------4-...
    
  • 相关阅读:
    亚马逊云IoT平台接入开发记录
    pip下载速度慢更换清华源试试
    gitlab回归上一次提交
    uos桌面壁纸存放路径
    python中json中的dump和dumps
    Python中的类中__dict__方法
    C++ | 数组反转的三种方法
    《C++Primer Plus》 | 复合类型
    pwn 中的函数 | 持续更新
    七月安恒DASCTF | 复现
  • 原文地址:https://www.cnblogs.com/xyJen/p/12781508.html
Copyright © 2011-2022 走看看