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

Commit 2bd9946

Browse files
chalinwardbell
authored andcommitted
example(toh-4,5): getHeroesSlowly() to return getHeroes() (#2152)
* example(dart/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. * 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 fd8fb70 commit 2bd9946

File tree

6 files changed

+8
-11
lines changed

6 files changed

+8
-11
lines changed

public/docs/_examples/toh-4/dart/lib/hero_service.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class HeroService {
1717
// See the "Take it slow" appendix
1818
// #docregion get-heroes-slowly
1919
Future<List<Hero>> getHeroesSlowly() {
20-
return new Future.delayed(const Duration(seconds: 2), () => mockHeroes);
20+
return new Future.delayed(const Duration(seconds: 2), getHeroes);
2121
}
2222
// #enddocregion get-heroes-slowly
2323
// #docregion

public/docs/_examples/toh-4/dart/lib/hero_service_1.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class HeroService {
1313
// #enddocregion getHeroes-stub, empty-class, final
1414
/*
1515
// #docregion getHeroes-stub
16-
List<Hero> getHeroes() {}
16+
List<Hero> getHeroes() {} // stub
1717
// #enddocregion getHeroes-stub
1818
*/
1919
// #docregion final

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

+1-2
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

+2-2
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/dart/lib/hero_service.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ import 'mock_heroes.dart';
1010
class HeroService {
1111
Future<List<Hero>> getHeroes() async => mockHeroes;
1212

13-
// See the "Take it slow" appendix
1413
Future<List<Hero>> getHeroesSlowly() {
1514
return new Future<List<Hero>>.delayed(
16-
const Duration(seconds: 2), () => mockHeroes);
15+
const Duration(seconds: 2), getHeroes);
1716
}
1817

1918
// #docregion getHero

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

+2-3
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)