Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Dec 4, 2017. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 856
docs(dependency-injection): revise Dart and TS code and prose#1573
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Empty file.
25 changes: 10 additions & 15 deletions
25 public/docs/_examples/dependency-injection/dart/lib/app_component.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10 public/docs/_examples/dependency-injection/dart/lib/app_component_1.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 8 additions & 5 deletions
13 public/docs/_examples/dependency-injection/dart/lib/app_component_2.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 21 additions & 11 deletions
32 public/docs/_examples/dependency-injection/dart/lib/app_config.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,27 @@ | ||
| // #docregion | ||
| // #docregion token | ||
| import 'package:angular2/core.dart'; | ||
| //#docregion const-class | ||
| @Injectable() | ||
| class AppConfig { | ||
| final apiEndpoint; | ||
| final String title; | ||
| const APP_CONFIG = const OpaqueToken('app.config'); | ||
| // #enddocregion token | ||
| // #docregion config | ||
| const Map heroDiConfig = const <String,String>{ | ||
| 'apiEndpoint' : 'api.heroes.com', | ||
| 'title' : 'Dependency Injection' | ||
| }; | ||
| // #enddocregion config | ||
| const AppConfig(this.apiEndpoint, this.title); | ||
| // #docregion config-alt | ||
| class AppConfig { | ||
| String apiEndpoint; | ||
| String title; | ||
| } | ||
| //#enddocregion const-class | ||
| //#docregion const-object | ||
| const config1 = const AppConfig('api.heroes.com', 'Dependency Injection'); | ||
| //#enddocregion const-object | ||
| AppConfig heroDiConfigFactory() => new AppConfig() | ||
| ..apiEndpoint = 'api.heroes.com' | ||
| ..title = 'Dependency Injection'; | ||
| // #enddocregion config-alt | ||
| const appConfigProvider = const Provider(APP_CONFIG, | ||
| useFactory: heroDiConfigFactory, | ||
| deps: const []); |
17 changes: 7 additions & 10 deletions
17 public/docs/_examples/dependency-injection/dart/lib/car/car.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 24 additions & 35 deletions
59 public/docs/_examples/dependency-injection/dart/lib/car/car_creations.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7 public/docs/_examples/dependency-injection/dart/lib/car/car_factory.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 13 additions & 22 deletions
35 public/docs/_examples/dependency-injection/dart/lib/car/car_injector.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,27 @@ | ||
| // #docplaster | ||
| //#docregion | ||
| import 'package:angular2/core.dart'; | ||
| import '../logger_service.dart'; | ||
| import 'car.dart'; | ||
| //#docregion injector | ||
| //#docregion injector | ||
| Car useInjector() { | ||
| ReflectiveInjector injector; | ||
| //#enddocregion injector | ||
| // #enddocregion injector | ||
| /* | ||
| //#docregion injector-no-new | ||
| // Cannot 'new' an ReflectiveInjector like this! | ||
| var injector = new ReflectiveInjector([Car, Engine, Tires, Logger]); | ||
| //#enddocregion injector-no-new | ||
| */ | ||
| //#docregion injector | ||
| //#docregion injector-create-and-call | ||
| injector = ReflectiveInjector.resolveAndCreate([Car, Engine, Tires, Logger]); | ||
| //#docregion injector-call | ||
| // #docregion injector-no-new | ||
| // Cannot instantiate an ReflectiveInjector like this! | ||
| var injector = new ReflectiveInjector([Car, Engine, Tires]); | ||
| // #enddocregion injector-no-new | ||
| */ | ||
| // #docregion injector, injector-create-and-call | ||
| injector = ReflectiveInjector.resolveAndCreate([Car, Engine, Tires]); | ||
| // #docregion injector-call | ||
| var car = injector.get(Car); | ||
| //#enddocregion injector-call | ||
| //#enddocregion injector-create-and-call | ||
| // #enddocregion injector-call, injector-create-and-call | ||
| car.description = 'Injector'; | ||
| injector = ReflectiveInjector.resolveAndCreate([Logger]); | ||
| var logger = injector.get(Logger); | ||
| logger.log('Injector car.drive() said: ' + car.drive()); | ||
| return car; | ||
| } | ||
| //#enddocregion injector | ||
| //#enddocregion |
3 changes: 2 additions & 1 deletion
3 public/docs/_examples/dependency-injection/dart/lib/car/car_no_di.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8 public/docs/_examples/dependency-injection/dart/lib/heroes/hero.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| // #docregion | ||
| class Hero { | ||
| num id; | ||
| String name; | ||
| bool isSecret = false; | ||
| final int id; | ||
| final String name; | ||
| final bool isSecret; | ||
| Hero(this.id, this.name, [this.isSecret = false]); | ||
| } |
7 changes: 4 additions & 3 deletions
7 public/docs/_examples/dependency-injection/dart/lib/heroes/hero_list_component.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 10 additions & 2 deletions
12 public/docs/_examples/dependency-injection/dart/lib/heroes/hero_list_component_2.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2 public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3 public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service_1.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| // #docregion | ||
| import 'package:angular2/core.dart'; | ||
| import 'hero.dart'; | ||
| import 'mock_heroes.dart'; | ||
| @Injectable() | ||
| class HeroService { | ||
| List<Hero> getHeroes() => HEROES; | ||
| } |
1 change: 0 additions & 1 deletion
1 public/docs/_examples/dependency-injection/dart/lib/heroes/hero_service_2.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APP_CONFIG seems like an un-Darty name. (But if it's mentioned in text, it'd be easier to leave this capitalization.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OpaqueToken section will need to be revisited once #1563 gets resolved so I decided to leave the token name like it is in the TS example (because then the token name and the interface name will match, both being
AppConfig).