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

Commit 705a045

Browse files
committed
example(ts/toh-4,5): getHeroesSlowly() to return getHeroes()
Have `getHeroesSlowly()` delay and then return the value of `getHeroes()`. This makes it easier for user’s performing the tutorial to keep this slower method as they evolve toh-5 into toh-6.
1 parent a9bfb90 commit 705a045

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ export class HeroService {
1313
// #enddocregion empty-class, getHeroes-stub, full
1414
/*
1515
// #docregion getHeroes-stub
16-
getHeroes(): void {
17-
}
16+
getHeroes(): void {} // stub
1817
// #enddocregion getHeroes-stub
1918
*/
2019
// #docregion full

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export class HeroService {
1818
// #docregion get-heroes-slowly
1919
getHeroesSlowly(): Promise<Hero[]> {
2020
return new Promise<Hero[]>(resolve =>
21-
setTimeout(() => resolve(HEROES), 2000) // 2 seconds
22-
);
21+
setTimeout(resolve, 2000)) // delay 2 seconds
22+
.then(() => this.getHeroes());
2323
}
2424
// #enddocregion get-heroes-slowly
2525
// #docregion

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ export class HeroService {
1010
return Promise.resolve(HEROES);
1111
}
1212

13-
// See the "Take it slow" appendix
1413
getHeroesSlowly(): Promise<Hero[]> {
1514
return new Promise<Hero[]>(resolve =>
16-
setTimeout(() => resolve(HEROES), 2000) // 2 seconds
17-
);
15+
setTimeout(resolve, 2000)) // delay 2 seconds
16+
.then(() => this.getHeroes());
1817
}
1918

2019
// #docregion getHero

0 commit comments

Comments
 (0)