From b7a9a4524f3d10cb4ab1731c02399106d91791aa Mon Sep 17 00:00:00 2001 From: Ward Bell Date: Thu, 15 Dec 2016 11:13:22 -0800 Subject: [PATCH] docs(toh): improve `getHeroesSlowly` in ToH-4/5 (#2443) (#2991) --- public/docs/_examples/toh-4/ts/app/hero.service.ts | 8 +++++--- public/docs/_examples/toh-5/ts/app/hero.service.ts | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/public/docs/_examples/toh-4/ts/app/hero.service.ts b/public/docs/_examples/toh-4/ts/app/hero.service.ts index 2b4de81c39..03a1c10a4a 100644 --- a/public/docs/_examples/toh-4/ts/app/hero.service.ts +++ b/public/docs/_examples/toh-4/ts/app/hero.service.ts @@ -14,12 +14,14 @@ export class HeroService { } // #enddocregion get-heroes, just-get-heroes // #enddocregion + // See the "Take it slow" appendix // #docregion get-heroes-slowly getHeroesSlowly(): Promise { - return new Promise(resolve => - setTimeout(resolve, 2000)) // delay 2 seconds - .then(() => this.getHeroes()); + return new Promise(resolve => { + // Simulate server latency with 2 second delay + setTimeout(() => resolve(this.getHeroes()), 2000); + }); } // #enddocregion get-heroes-slowly // #docregion diff --git a/public/docs/_examples/toh-5/ts/app/hero.service.ts b/public/docs/_examples/toh-5/ts/app/hero.service.ts index 163734fe5f..ee5a684762 100644 --- a/public/docs/_examples/toh-5/ts/app/hero.service.ts +++ b/public/docs/_examples/toh-5/ts/app/hero.service.ts @@ -11,9 +11,10 @@ export class HeroService { } getHeroesSlowly(): Promise { - return new Promise(resolve => - setTimeout(resolve, 2000)) // delay 2 seconds - .then(() => this.getHeroes()); + return new Promise(resolve => { + // Simulate server latency with 2 second delay + setTimeout(() => resolve(this.getHeroes()), 2000); + }); } // #docregion getHero