RxJS is super when dealing with the dynamic value.

Let's see an example which not using RxJS:

var a = 4;
var b = a * 10; console.log(b); // a = 5;
console.log(b); //

So you change a, it won't affect b's value because b is already defined....

So if you want b get sideeffect, you need to declear it again:

var a = 4;
var b = a * 10; console.log(b); // a = 5;
b = a * 12;
console.log(b); //

And also, many a time, it may happened that you found the variable has been mutated, but you have no idea where and how.

So using RxJS:

var streamA = Rx.Observable.interval(400).take(5);
var streamB = streamA.map( (num) => {
return num * 10;
}) streamB.subscribe(b => console.log(b));

SO now, streamA arrivals at every 400ms, we can take 4 of those. then we map to StreamB.

Then in the console, you will see the value will change according to the value of stream A.

[RxJS] Reactive Programming - Why choose RxJS?的更多相关文章

  1. [RxJS] Reactive Programming - What is RxJS?

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

  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. JavaLearning:JAVA IO Piped流

    package org.fun.io; import java.io.IOException; import java.io.PipedInputStream; import java.io.Pipe ...

  2. 将宿主机东西拷贝到dokcer容器中去

    1,获取容器名称或者id : docker ps 2,获取整个容器的id,其实键盘tag就可以补全的. docker inspect -f  '{{.Id}}'  步骤A获取的名称或者id 3,在主机 ...

  3. C#遍历Object各个属性含List泛型嵌套。

    同事遇到一个问题:在做手机app接口时,返回JSON格式,json里面的数据属性均是string类型,但不能出现NULL(手机端那边说处理很麻烦,哎).Model已经创建好了,而且model的每个属性 ...

  4. avalon学习笔记一 列表及条件过滤

    好长时间都没有更新博客了,不是因为没有学习新的东西,而是到了新的单位每天玩命加班实在是太累了!经过一年的努力吧,终于可以轻松一下了.废话少说,直接干货吧! 由于是学习阶段,就直接拿了公司的二级页面做了 ...

  5. (转)CommandArgument用法

    1.绑定数据库中一个主键前台代码:<ItemTemplate>                        <asp:ImageButton ID="ibtnUpdate ...

  6. OpenGL ES 2.0 绘制方式

    OpenGL ES 中支持的绘制方式大致分3类,包括点.线段.三角形,每类中包括一种或多种具体的绘制方式. GL_POINTS 传入渲染管线的一系列顶点单独进行绘制. GL_LINES   传入渲染管 ...

  7. poj1915 BFS

    D - 广搜 基础 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:30000KB     64bi ...

  8. mysql 权限分配及创建新用户

    前言 本文主要是介绍mysql创建新用户命令及赋予权限等命令,为了便于理解,文中会给出相关示例.通常情况下,创建用户,修改mysql密码,授权,是需要有mysql里的root权限. 1.创建用户: / ...

  9. javascript中0级DOM和2级DOM事件模型浅析

    Javascript程序使用的是事件驱动的设计模式,为一个元素添加事件监听函数,当这个元素的相应事件被触发那么其添加的事件监听函数就被调用: <input type="button&q ...

  10. php 简单分页

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...