docs: fix multicasting example in observable guide (#24911)

PR Close #24911
This commit is contained in:
Mateusz Karkula 2018-07-16 21:02:58 +02:00 committed by Victor Berchet
parent 168c2a645b
commit bd576bb83f
1 changed files with 4 additions and 4 deletions

View File

@ -15,7 +15,7 @@ function sequenceSubscriber(observer) {
if (idx === arr.length - 1) {
observer.complete();
} else {
doSequence(arr, idx++);
doSequence(arr, ++idx);
}
}, 1000);
}
@ -95,7 +95,7 @@ function multicastSequenceSubscriber() {
},
complete() {
// Notify all complete callbacks
observers.forEach(obs => obs.complete());
observers.slice(0).forEach(obs => obs.complete());
}
}, seq, 0);
}
@ -121,13 +121,13 @@ function doSequence(observer, arr, idx) {
if (idx === arr.length - 1) {
observer.complete();
} else {
doSequence(observer, arr, idx++);
doSequence(observer, arr, ++idx);
}
}, 1000);
}
// Create a new Observable that will deliver the above sequence
const multicastSequence = new Observable(multicastSequenceSubscriber);
const multicastSequence = new Observable(multicastSequenceSubscriber());
// Subscribe starts the clock, and begins to emit after 1 second
multicastSequence.subscribe({