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. BGP

    http://network.51cto.com/art/200912/172439.htm http://blog.sina.com.cn/s/blog_b457dde80101cyqr.html ...

  2. 页面全部加载完毕和页面dom树加载完毕

    dom树加载完毕 $(document).ready()//原生写法document.ready = function (callback) {            ///兼容FF,Google   ...

  3. C#的位运算符

    C#的位运算符&,| ,^ ,<<,>>2008年08月01日 星期五 15:52位 运 算我们知道任何信息在计算机中都是以二进制的形式保存的位操作符就是对数据按二进制 ...

  4. FpSpread添加标注

    先看效果 实现: FarPoint.Web.Spread.StyleInfo Errorcss = new FarPoint.Web.Spread.StyleInfo(); Errorcss.Bord ...

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

    1.活动-一种可以包含用户界面的组件,用于和用户进行交互. <Button android:id="@+id/button_1" android:layout_width=& ...

  6. SQL 增加或删除一列

    SQL 增加或删除一列 alter table tablename drop column columnname;alter table tabelname add columnname varcha ...

  7. Linux下MySql启动时报错

    /opt/mysql/support-files/mysql.server startmy_print_defaults: [ERROR] Found option without preceding ...

  8. 修改UITextfield的Placeholder字体的颜色

    - (void)viewDidLoad { [super viewDidLoad]; self.title=@"修改UITextField的placeholder字体颜色"; UI ...

  9. 关于Jquery.validate.js中动态删除验证remove方法的Bug

    利用Jquery.validate.js 来做动态验证的时候,需要特定的情况下,删除添加opAmount的必须入力的Check $("#form").validate({ rule ...

  10. POJ 1002 - 487-3279 STL

    先把不是标准格式的字符串变成标准格式再输出出现两次以上的标准串和出现的次数不然输出 "No duplicates." #include <iostream> #incl ...