[Reactive Programming] RxJS dynamic behavior

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);
});
原文地址:https://www.cnblogs.com/Answer1215/p/4852331.html