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): add Dart version, tweak TS version #972
Closed
Closed
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
3b52317
Straight copy of content, no changes except a few omissions
kwalrath 1bbbc27
Include Dart samples, not TS samples.
kwalrath 10dab8a
shorten line length in some sample code
kwalrath 74cd216
Tweak samples
kwalrath 46a4a9a
tweak code
kwalrath 2b18715
first draft of Dart text
kwalrath f13d0fd
make output of Dart app match TS app's output
kwalrath 505f720
fix script tags in index.html
kwalrath ea1b774
sample cleanup
kwalrath b362c1d
more code cleanups
kwalrath 614a49b
midway through incorporating thso's comments...
kwalrath 0d7fbc4
a few more changes, incorporating thso's feedback
kwalrath 9409bb4
code tweaks suggested by thso
kwalrath 39d0b6f
delete "we probably already know" filler...
kwalrath 225f3b4
incorporate more comments from thso
kwalrath 835cfbb
user core.dart, b.12, much new code
kwalrath 537a5c9
Change appConfig to use a class (and still useValue)
kwalrath 5f40a6e
fix text to reflect new code
kwalrath e51f569
clean up last section and code includes
kwalrath a145b2d
final cleanup!
kwalrath 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
16 changes: 16 additions & 0 deletions
16
public/docs/_examples/dependency-injection/dart/.analysis_options
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Supported lint rules and documentation: http://dart-lang.github.io/linter/lints/ | ||
linter: | ||
rules: | ||
- always_declare_return_types | ||
- camel_case_types | ||
- empty_constructor_bodies | ||
- annotate_overrides | ||
- avoid_init_to_null | ||
- constant_identifier_names | ||
- one_member_abstracts | ||
- slash_for_doc_comments | ||
- sort_constructors_first | ||
- unnecessary_brace_in_string_interp | ||
|
||
analyzer: | ||
# strong-mode: true |
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: 10 additions & 22 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,29 +1,17 @@ | ||
//#docregion | ||
|
||
// #docregion | ||
// #docregion token | ||
import 'package:angular2/core.dart'; | ||
|
||
const APP_CONFIG = const OpaqueToken('app.config'); | ||
// #enddocregion token | ||
|
||
//#docregion config | ||
abstract class Config { | ||
final String apiEndpoint; | ||
//#docregion const-class | ||
@Injectable() | ||
class AppConfig { | ||
final apiEndpoint; | ||
final String title; | ||
|
||
const Config({this.apiEndpoint, this.title}); | ||
const AppConfig(this.apiEndpoint, this.title); | ||
} | ||
//#enddocregion const-class | ||
|
||
class ConfigImpl implements Config { | ||
final String apiEndpoint; | ||
final String title; | ||
|
||
const ConfigImpl({this.apiEndpoint, this.title}); | ||
} | ||
|
||
const CONFIG = const ConfigImpl(apiEndpoint: 'api.heroes.com', title: 'Dependency Injection'); | ||
//#enddocregion config | ||
|
||
//#docregion config-hash | ||
const CONFIG_HASH = const {'apiEndpoint': 'api.heroes.com', 'title': 'Dependency Injection'}; | ||
//#enddocregion config-hash | ||
//#docregion const-object | ||
const config1 = const AppConfig('api.heroes.com', 'Dependency Injection'); | ||
//#enddocregion const-object |
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
28 changes: 14 additions & 14 deletions
28
public/docs/_examples/dependency-injection/dart/lib/car/car_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
// #docregion | ||
|
||
import 'package:angular2/core.dart'; | ||
|
||
import 'car.dart'; | ||
import 'car_no_di.dart' as carNoDi; | ||
import 'car_factory.dart'; | ||
import 'car_creations.dart' as carCreations; | ||
import 'car_factory.dart'; | ||
import 'car_injector.dart'; | ||
import 'car_no_di.dart' as carNoDi; | ||
|
||
@Component( | ||
selector: 'my-car', | ||
template: ''' | ||
<h2>Cars</h2> | ||
<div id="di">{{car.drive()}}</div> | ||
<div id="nodi">{{noDiCar.drive()}}</div> | ||
<div id="injector">{{injectorCar.drive()}}</div> | ||
<div id="factory">{{factoryCar.drive()}}</div> | ||
<div id="simple">{{simpleCar.drive()}}</div> | ||
<div id="super">{{superCar.drive()}}</div> | ||
<div id="test">{{testCar.drive()}}</div> | ||
''', | ||
<h2>Cars</h2> | ||
<div id="di">{{car.drive()}}</div> | ||
<div id="nodi">{{noDiCar.drive()}}</div> | ||
<div id="injector">{{injectorCar.drive()}}</div> | ||
<div id="factory">{{factoryCar.drive()}}</div> | ||
<div id="simple">{{simpleCar.drive()}}</div> | ||
<div id="super">{{superCar.drive()}}</div> | ||
<div id="test">{{testCar.drive()}}</div>''', | ||
providers: const [Car, Engine, Tires]) | ||
class CarComponent { | ||
Car car; | ||
final Car car; | ||
|
||
CarComponent(this.car); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: newline after ctor. |
||
|
||
CarComponent(this.car) {} | ||
Car factoryCar = (new CarFactory()).createCar(); | ||
Car injectorCar = useInjector(); | ||
carNoDi.Car noDiCar = new carNoDi.Car(); | ||
|
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: 3 additions & 5 deletions
8
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
// #docregion | ||
|
||
import 'car.dart'; | ||
|
||
// BAD pattern! | ||
class CarFactory { | ||
Car createCar() { | ||
var car = new Car(createEngine(), createTires()); | ||
car.description = 'Factory'; | ||
return car; | ||
return new Car(createEngine(), createTires()) | ||
..description = 'Factory'; | ||
} | ||
|
||
Engine createEngine() => new Engine(); | ||
|
||
Tires createTires() => new Tires(); | ||
} |
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.
: title = config.title;