jjzjj

stringVariable

全部标签

javascript - RxJS:如何包装和观察字符串的变化?

RxJS:如何将原始类型(例如string)包装在Observable中并监听该原始类型的变化?考虑以下示例。setTimeout模拟一些改变字符串s的外部事件。但是,console.log仅触发一次,而不是在调用setTimeout之后触发。这是为什么?lets="HelloWorld";Observable.of(s).subscribe(val=>{console.log(val);});//someexternaleventchangesvariablessetTimeout(()=>{s="Wat?";},1000);//Output:prints"HelloWorld"to