From bd576bb83f6a2a51f2463b1e2cddc523130d41ab Mon Sep 17 00:00:00 2001 From: Mateusz Karkula Date: Mon, 16 Jul 2018 21:02:58 +0200 Subject: [PATCH] docs: fix multicasting example in observable guide (#24911) PR Close #24911 --- aio/content/examples/observables/src/multicasting.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aio/content/examples/observables/src/multicasting.ts b/aio/content/examples/observables/src/multicasting.ts index 449f7b73c7..e8275842f0 100644 --- a/aio/content/examples/observables/src/multicasting.ts +++ b/aio/content/examples/observables/src/multicasting.ts @@ -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({