Ich habe eine Abfrage in Bezug auf RxJS combineLatest Operator. Ich habe das Beispiel inRxJS combineLatest Betreiber seltsames Verhalten
https://www.learnrxjs.io/operators/combination/combinelatest.html
gegeben wie folgt geändert:
//timerOne emits first value at 1s, then once every 4s
const timerOne = Rx.Observable.timer(1000, 4000);
//timerTwo emits first value at 2s, then once every 4s
const timerTwo = Rx.Observable.timer(2000, 4000)
//timerThree emits first value at 3s, then once every 4s
const timerThree = Rx.Observable.of(false);
//when one timer emits, emit the latest values from each timer as an array
const combined = Rx.Observable
.combineLatest(
timerOne,
timerTwo,
timerThree
);
const subscribe = combined.subscribe(latestValues => {
//grab latest emitted values for timers one, two, and three
const [timerValOne, timerValTwo, timerValThree] = latestValues;
if(latestValues[0] === 3) {
this.timerThree = Rx.Observable.of(true);
}
console.log(
`Timer One Latest: ${timerValOne},
Timer Two Latest: ${timerValTwo},
Timer Three Latest: ${timerValThree}`
);
});
ich den Wert von timerThree erwarten wahr ändern Bit halten sie immer auf den Druck falsch wie in das Ausgabesnippet:
"Timer One Latest: 3,
Timer Two Latest: 2,
Timer Three Latest: false"
"Timer One Latest: 3,
Timer Two Latest: 3,
Timer Three Latest: false"
"Timer One Latest: 4,
Timer Two Latest: 3,
Timer Three Latest: false"
Irgendeine Idee warum t ist es passiert? Gibt es eine Möglichkeit, das zu beheben? Danke