From 8f63ba88e58a4be503324146ead3a36b85a1fc5d Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Thu, 5 Jan 2017 13:40:48 -0800 Subject: [PATCH] refactor(observeOn-spec): use a scheduler instead of setInterval The idea here is to promote a more consistent scheduling of each value across multiple browsers. It seems there were some concurrency problems when this test was run in Microsoft Edge. Hopefully this clears it up. related #2244 --- spec/operators/observeOn-spec.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/operators/observeOn-spec.ts b/spec/operators/observeOn-spec.ts index 431973b917..8e4a10b2d9 100644 --- a/spec/operators/observeOn-spec.ts +++ b/spec/operators/observeOn-spec.ts @@ -84,17 +84,18 @@ describe('Observable.prototype.observeOn', () => { //HACK: Deep introspection to make sure we're cleaning up notifications in scheduling. // as the architecture changes, this test may become brittle. const results = []; + // This is to build a scheduled observable with a slightly more stable + // subscription structure, since we're going to hack in to analyze it in this test. const subscription: any = new Observable(observer => { let i = 1; - const id = setInterval(() => { + return Rx.Scheduler.asap.schedule(function () { if (i > 3) { observer.complete(); } else { observer.next(i++); + this.schedule(); } - }, 0); - - return () => clearInterval(id); + }); }) .observeOn(Rx.Scheduler.asap) .subscribe(