码迷,mamicode.com
首页 > Web开发 > 详细

[Reactive Programming] RxJS dynamic behavior

时间:2015-10-02 17:20:47      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

This lesson helps you think in Reactive programming by explaining why it is a beneficial paradigm for programming. See how reactive programming helps you understand the dynamic behavior of a value evolving over time.

 

It allows you to specify the dynamic behavior of a value completely at the time of declaration.

 

console.clear();
var a = 3;
var b = a * 10;

console.log(b);

// Then if you want to change ‘a‘ and wants ‘b‘ change accordingly
// You need to declare b again 
var a = 4;
b = a * 10;
console.log(b);

console.log("Reactive Progarmming");

// You need to declare all the dynamic behavior at first
// Here for example you need to change a to 4 or 5
var streamA = Rx.Observable.of(3, 4, 5);
var streamB = streamA.map((a) => {
  return a * 10;
});

streamB.subscribe(function(b){
  console.log(b);
});

 

[Reactive Programming] RxJS dynamic behavior

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/4852331.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!