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 877
docs(dependency-injection): revise Dart and TS code and prose #1573
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Whitespace-only changes.
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
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
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 []); |
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
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
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
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
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]); | ||
} |
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: 8 additions & 0 deletions
8
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
Whitespace-only changes.
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; | ||
} |
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
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.
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
).