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. PCM文件格式简单介绍

    PCM文件格式简单介绍 PCM文件:模拟音频信号经模数转换(A/D变换)直接形成的二进制序列,该文件没有附加的文件头和文件结束标志.Windows的Convert工具能够把PCM音频格式的文件转换成M ...

  2. UITableView的简单总结与回顾

    今天突发奇想的想对UItableView做一下汇总,感觉在编程中这个控件可以千变万化也是用的最多的一个了,下面就为大家简单总结下这个控件,也许还有不足,不过还是请各位不吝赐教了哈,那么我就开始了,我会 ...

  3. _js day11

  4. asp Eval()函数的一些使用总结

    一.函数的原型: Eval(string s); s可以是变量,表达式,语句: 二.使用: 1.s为变量时,返回该变量的值,如:string s = "sss";Eval(s);/ ...

  5. JavaScript操作剪贴板(转)

    IE是第一个支持与剪贴板相关的事件,以及通过JavaScript访问剪贴板数据的浏览器.IE的实现成为了某种标准,不仅Safari 2.Chrome和Firefox 3也都支持类似的事件和剪贴板(Op ...

  6. 《第一行代码》学习笔记5-活动Activity(3)

    1.Menu:让菜单得到展示的同时,不占用任何屏幕的空间. public boolean onCreateOptionsMenu(Menu menu){ getMenuInflater().infla ...

  7. static说明

    1.最基本用法:加static的全局变量或者函数,只能在本文件中使用.可见性只在本文件中. 当我们同时编译多个文件时,所有未加static前缀的全局变量和函数都具有全局可见性.为理解这句话,我举例来说 ...

  8. .Net 插入数据MySql数据库,中文乱码解决问题

    1, 修改mysql根目录下配置文件my.ini,在[client]节点下添加default-character-set=utf8 ,在[mysqld]节点下添加character_set_serve ...

  9. Java根据字节数据判断文件类型

    通常,在WEB系统中,上传文件时都需要做文件的类型校验,大致有如下几种方法: 1. 通过后缀名,如exe,jpg,bmp,rar,zip等等. 2. 通过读取文件,获取文件的Content-type来 ...

  10. 用python随机生成数据,再插入到postgresql中

    用python随机生成学生姓名,三科成绩和班级数据,再插入到postgresql中. 模块用psycopg2 random import random import psycopg2 fname=[' ...