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

chore(dart): updating to beta.16 #1192

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/docs/_examples/architecture/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ import 'car.dart';

//#docregion injector
Car useInjector() {
Injector injector;
ReflectiveInjector injector;
//#enddocregion injector

/*
//#docregion injector-no-new
// Cannot 'new' an Injector like this!
var injector = new Injector([Car, Engine, Tires, Logger]);
// 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 = Injector.resolveAndCreate([Car, Engine, Tires, Logger]);
injector = ReflectiveInjector.resolveAndCreate([Car, Engine, Tires, Logger]);
//#docregion injector-call
var car = injector.get(Car);
//#enddocregion injector-call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ class InjectorComponent {
Hero hero;

String get rodent {
var rous = _injector.getOptional(ROUS);
if (rous != null) {
throw new Exception('Aaaargh!');
try {
_injector.get(ROUS);
} on NoProviderError {
return "R.O.U.S.'s? I don't think they exist!";
}
return "R.O.U.S.'s? I don't think they exist!";
throw new Exception('Aaaargh!');
}

InjectorComponent(this._injector) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
2 changes: 1 addition & 1 deletion public/docs/_examples/displaying-data/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
2 changes: 1 addition & 1 deletion public/docs/_examples/forms/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
2 changes: 1 addition & 1 deletion public/docs/_examples/lifecycle-hooks/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
30 changes: 12 additions & 18 deletions public/docs/_examples/pipes/dart/lib/exponential_strength_pipe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,18 @@ import 'dart:math' as math;
import 'package:angular2/angular2.dart';

/*
* Raise the value exponentially
* Takes a value that defaults to 0 and an exponent argument that defaults to 1.
* Checks for value to be a string or number.
* Usage:
* value | exponentialStrength:exponent
* Example:
* {{ 2 | exponentialStrength:10}}
* formats to: 1024
*/

* Raise the value exponentially
* Takes an exponent argument that defaults to 1.
* Usage:
* value | exponentialStrength:exponent
* Example:
* {{ 2 | exponentialStrength:10}}
* formats to: 1024
*/
@Pipe(name: 'exponentialStrength')
@Injectable()
@Injectable() // FIXME(chalin): unnecessary?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HeroService doesn't have any dependencies at the moment. Add the decorator anyway. It is a "best practice" to apply the @Injectable() decorator ​from the start​ both for consistency and for future-proofing.

From https://angular.io/docs/ts/latest/tutorial/toh-pt4.html

Event though it's not necessary, per style guide it should be added to all classes that are supposed to be injected.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw. It's a Pipe. @Pipe like @Component() and @Directive() don't need an additional @Injectable()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is what I thought, but I wanted to double check in case there was a nonstandard case where it might have been necessary. Thanks for confirming. @thso do you agree?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All core pipes have the @Injectable() annotation: https://github.com/angular/angular/blob/master/modules/angular2/src/common/pipes/lowercase_pipe.ts

But I'm not convinced either that it's effectively required. Just try and build your app and see if everything still work without it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will be glad to try that out once angular/angular#8258 is fixed :). What do you suggest in the meantime? As I pointed out elsewhere, this example will need to be fully revised soon.

class ExponentialStrengthPipe extends PipeTransform {
transform(dynamic value, [List<dynamic> args]) {
var v = int.parse(value.toString(), onError: (source) => 0);
var p = args.isEmpty
? 1
: int.parse(args.first.toString(), onError: (source) => 1);
return math.pow(v, p);
}
num transform(num value, String exponent) =>
math.pow(value,
num.parse(exponent, onError: (_) => 1));
}
10 changes: 7 additions & 3 deletions public/docs/_examples/pipes/dart/lib/fetch_json_pipe.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
// #docregion
import 'dart:html';
import 'dart:async';
import 'dart:convert';

import 'package:angular2/angular2.dart';

// #docregion pipe-metadata
@Pipe(name: 'fetch', pure: false)
@Injectable()
// #enddocregion pipe-metadata
@Injectable() // FIXME(chalin): unnecessary?
class FetchJsonPipe extends PipeTransform {
dynamic _fetchedValue;
Future<dynamic> _fetchPromise;
transform(dynamic value, [List<dynamic> args]) {

transform(String url) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that bothered me too, but given that this example doesn't run anymore in beta.16, I decided to stop making changes. The entire example needs revision anyhow. For now, I need to focus on getting the Dart version of the prose out. I will revise this example once I get to the pipes chapter.

if (_fetchPromise == null) {
_fetchPromise = new Future(() async {
_fetchedValue = JSON.decode(await HttpRequest.getString(value));
_fetchedValue = JSON.decode(await HttpRequest.getString(url));
});
}
return _fetchedValue;
Expand Down
2 changes: 1 addition & 1 deletion public/docs/_examples/pipes/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
2 changes: 1 addition & 1 deletion public/docs/_examples/quickstart/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
# #enddocregion no-rewriter
dart_to_js_script_rewriter: ^1.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
2 changes: 1 addition & 1 deletion public/docs/_examples/template-syntax/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
2 changes: 1 addition & 1 deletion public/docs/_examples/toh-1/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
2 changes: 1 addition & 1 deletion public/docs/_examples/toh-2/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
2 changes: 1 addition & 1 deletion public/docs/_examples/toh-3/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
2 changes: 1 addition & 1 deletion public/docs/_examples/toh-4/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
2 changes: 1 addition & 1 deletion public/docs/_examples/toh-5/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
2 changes: 1 addition & 1 deletion public/docs/_examples/user-input/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.15
angular2: 2.0.0-beta.16
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
Expand Down
2 changes: 1 addition & 1 deletion public/docs/dart/latest/_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"icon": "home",
"title": "Angular Docs",
"menuTitle": "Docs Home",
"banner": "Welcome to <b>angular.io/dart</b>! The current Angular 2 release is <b>beta.15</b>. Consult the <a href='https://github.com/angular/angular/blob/master/CHANGELOG.md' target='_blank'>Change Log</a> about recent enhancements, fixes, and breaking changes."
"banner": "Welcome to <b>angular.io/dart</b>! The current Angular 2 release is <b>beta.16</b>. Consult the <a href='https://github.com/angular/angular/blob/master/CHANGELOG.md' target='_blank'>Change Log</a> about recent enhancements, fixes, and breaking changes."
},

"quickstart": {
Expand Down
2 changes: 1 addition & 1 deletion public/docs/dart/latest/quickstart.jade
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ p.
specify the angular2 and browser packages as dependencies,
as well as the angular2 transformer.
Angular 2 is still changing, so provide an exact version:
<b>2.0.0-beta.15</b>.
<b>2.0.0-beta.16</b>.

+makeExample('quickstart/dart/pubspec.yaml', 'no-rewriter', 'pubspec.yaml')

Expand Down