我有以下代碼:爲什麼Rx.Observable.of(真)開始發射
console.log('start');
//emit value every second
const message = Rx.Observable.interval(1000);
//emit value as soon as subscribed
const trueObs =() => Rx.Observable.of(true);
// start emitting delayed values as soon as trueObs emits
const delayWhenExample = message.delayWhen(trueObs);
//log values start logging after one second
//ex. output: 0...1...2...3
const subscribe = delayWhenExample.subscribe(val => console.log(val));
<script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.umd.js"></script>
爲什麼Rx.Observable.of(true)
開始不subscribe
可觀察到發射值?
我理解到RxJS作爲懶惰評估的概念,它不會發出值,直到我問它。
我不確定我是否理解這個問題。你在最後一行叫'訂閱'。 –
但我確實訂閱'message' observable不是'delayForFiveSeconds' –