首页 > Web开发 > 详细

[Reactive Programming] RxJS dynamic behavior

时间:2015-10-02 17:19:47      阅读:340      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!