Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit b7a9a45

Browse files
authored
docs(toh): improve getHeroesSlowly in ToH-4/5 (#2443) (#2991)
1 parent 562c629 commit b7a9a45

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

public/docs/_examples/toh-4/ts/app/hero.service.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ export class HeroService {
1414
}
1515
// #enddocregion get-heroes, just-get-heroes
1616
// #enddocregion
17+
1718
// See the "Take it slow" appendix
1819
// #docregion get-heroes-slowly
1920
getHeroesSlowly(): Promise<Hero[]> {
20-
return new Promise<Hero[]>(resolve =>
21-
setTimeout(resolve, 2000)) // delay 2 seconds
22-
.then(() => this.getHeroes());
21+
return new Promise(resolve => {
22+
// Simulate server latency with 2 second delay
23+
setTimeout(() => resolve(this.getHeroes()), 2000);
24+
});
2325
}
2426
// #enddocregion get-heroes-slowly
2527
// #docregion

public/docs/_examples/toh-5/ts/app/hero.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ export class HeroService {
1111
}
1212

1313
getHeroesSlowly(): Promise<Hero[]> {
14-
return new Promise<Hero[]>(resolve =>
15-
setTimeout(resolve, 2000)) // delay 2 seconds
16-
.then(() => this.getHeroes());
14+
return new Promise(resolve => {
15+
// Simulate server latency with 2 second delay
16+
setTimeout(() => resolve(this.getHeroes()), 2000);
17+
});
1718
}
1819

1920
// #docregion getHero

0 commit comments

Comments
 (0)