First thing need to understand is, Reactive programming is dealing with the event stream.

Event streams happens overtime, which not stay in the memory.

For example, the array we have:

var source = ['1', '1', 'foo', '2', '3', '5', 'bar', '8', '13'];

Which is stay in the momery.

But the stream we have:

let logic = Rx.Observable.interval(400).take(9)
.map( (i) => {
let val = ['1', '1', 'foo', '2', '3', '5', 'bar', '8', '13'][i]
return parseInt(val, 10);
})

Which happens overtime, every 400ms it return an Interge if possible.

So the main difference between array stay in memory and the events streams is array already stay in memory and the streams happens overtime.

But the nice things about the stream is we can still use the methods we have for array:

let logic = Rx.Observable.interval(400).take(9)
.map( (i) => {
let val = ['1', '1', 'foo', '2', '3', '5', 'bar', '8', '13'][i]
return parseInt(val, 10);
})
.filter( (number) => {
return !isNaN(number)
})
.reduce( (acc, y) => {
return acc + y;
} ); let effect = logic.subscribe( (number) => {
console.log(number);
});

[RxJS] Reactive Programming - What is RxJS?的更多相关文章

  1. [RxJS] Reactive Programming - Why choose RxJS?

    RxJS is super when dealing with the dynamic value. Let's see an example which not using RxJS: var a ...

  2. [RxJS] Reactive Programming - Clear data while loading with RxJS startWith()

    In currently implemention, there is one problem, when the page load and click refresh button, the us ...

  3. [RxJS] Reactive Programming - Rendering on the DOM with RxJS

    <!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery- ...

  4. [RxJS] Reactive Programming - Using cached network data with RxJS -- withLatestFrom()

    So now we want to replace one user when we click the 'x' button. To do that, we want: 1. Get the cac ...

  5. [RxJS] Reactive Programming - Sharing network requests with shareReplay()

    Currently we show three users in the list, it actually do three time network request, we can verfiy ...

  6. [RxJS] Reactive Programming - New requests from refresh clicks -- merge()

    Now we want each time we click refresh button, we will get new group of users. So we need to get the ...

  7. [Reactive Programming] RxJS dynamic behavior

    This lesson helps you think in Reactive programming by explaining why it is a beneficial paradigm fo ...

  8. .Net中的反应式编程(Reactive Programming)

    系列主题:基于消息的软件架构模型演变 一.反应式编程(Reactive Programming) 1.什么是反应式编程:反应式编程(Reactive programming)简称Rx,他是一个使用LI ...

  9. [Reactive Programming] Using an event stream of double clicks -- buffer()

    See a practical example of reactive programming in JavaScript and the DOM. Learn how to detect doubl ...

随机推荐

  1. HDU 3265 Posters(线段树)

    HDU 3265 Posters pid=3265" target="_blank" style="">题目链接 题意:给定一些矩形海报.中间有 ...

  2. top 命令SQLServer-sybase-oracle

    SQLServer: select top 10 * from tablename; select top 10 percent from tablename; select * from table ...

  3. ORacle 复制表

    create table r_register_company as select companyid,companyname,from grdata.r_register_company inser ...

  4. C#读取USB的一些相关信息

    在USB\VID_05A9&PID_2800\5&1BFE1C47&0&8里面,USB代表设备类型,5&1BFE1C47&0&8代表设备连接位置 ...

  5. javaScript中获取鼠标位置的理解

    获取鼠标坐标值的总结为了避免混淆知识点 通过<javaScript高级程序设计>查到这些 event.clientX event.clientY event.pageX event.pag ...

  6. C++中explicit

    [explicit] 1.用于抑制隐式转换,即: X x = ; // error X x(); // ok 2.只对一个实参的构造函数有效,但是,可以用多有多个实参的构造函数,目前没有意义: cla ...

  7. winPcap_6_不用回调方法捕获数据包

    用 pcap_next_ex() 函数代替 _5_ 中的 pcap_loop()函数: pcap_loop()函数是基于回调的原理来进行数据捕获,这是一种精妙的方法,并且在某些场合中,它是一种很好的选 ...

  8. 一个Restful Api的访问控制方法

    最近在做的两个项目,都需要使用Restful Api,接口的安全性和访问控制便成为一个问题,看了一下别家的API访问控制办法. 新浪的API访问控制使用的是AccessToken,有两种方式来使用该A ...

  9. uva 227 Puzzle

     Puzzle  A children's puzzle that was popular 30 years ago consisted of a 5x5 frame which contained ...

  10. C语言日期时间标准库

    用思维导图整理: 代码: #include <stdio.h> #include <time.h> #include <string.h> int main() { ...