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. LRU Cache的简单c++实现

    什么是 LRU LRU Cache是一个Cache的置换算法,含义是“最近最少使用”,把满足“最近最少使用”的数据从Cache中剔除出去,并且保证Cache中第一个数据是最近刚刚访问的,因为这样的数据 ...

  2. OLE-DB 操作excel 基本

    1 方法用例   *&---------------------------------------------------------------------* *& 本程序总结了常 ...

  3. DIV 与 Table 嵌套

    当然可以了.对于DIV定义表示一块可显示 HTML 的区域. Specifies a container that renders HTML. 注释此元素在 Internet Explorer 3.0 ...

  4. C#递归算法详解

    递归呢就是自己调用自己,在搜索文件夹下的文件和目录时也能用到,我这里就写一个简单的递归,代码如下: /// <summary> /// 递归算法 /// </summary> ...

  5. Gson源码分析之Json结构抽象和注解使用

    github上的博客地址: http://chuyun923.github.io/blog/2015/01/06/gsonyuan-ma-fen-xi/ XML和Json作为最常用的两种网络传输格式而 ...

  6. Visual Studio 命中断点时 打印信息

    打印时间: 开始: {DateTime.Now.ToString()} 结束: {DateTime.Now.ToString()} 搜索 复制

  7. sql server数据库将excel表中的数据导入数据表

    一般有两种方法可以实现,一种是直接写sql语句,另外一种是利用sqlserver的管理工具实现.这里介绍的是后面一种方法. 步骤: 一.准备数据 1.将excel表另存为文本格式,注意文本格式需为ta ...

  8. ASP.net MVC 向子视图传递数据

    使用 RenderPage 加载子视图 @RenderPage("~/Shared/Component/Dialog.cshtml", new { title = "He ...

  9. CentOS磁盘分区、格式化并挂载外置存储的方法

    1.划分外置存储主分区: 假设该外置存储在linux系统中被识别为/dev/sdb,使用fdisk /dev/sdb进入分区工具操作界面. 按p键打印当前外置存储分区情况,如果显示为空,则表示此外置存 ...

  10. 练习—单链表—Swap Nodes in Pairs

    Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2-& ...