您的位置:首页 > Web前端 > React

[Reactive Programming] RxJS dynamic behavior

2015-10-02 16:04 591 查看
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);
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: