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

Commit da48db3

Browse files
chalinkwalrath
authored andcommitted
docs(server-communication): cleanup, mainly for Dart (#1455)
- Dart code: fix issues raised by @thso during review. - Dart code: remove "show x" clauses from imports. - Dart add docsync config file. - Prose: make consistent use of _Http variables; otherwise use "HTTP". - Prose: add links to the demos list. * _heroesUrl as static const
1 parent 6d2d52c commit da48db3

File tree

11 files changed

+45
-48
lines changed

11 files changed

+45
-48
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "HTTP client (server communication)"
3+
"docHref": "https://angular.io/docs/dart/latest/guide/server-communication.html"
4+
}

public/docs/_examples/server-communication/dart/lib/app_component.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// #docplaster
22
// #docregion
3-
import "package:angular2/core.dart" show Component;
3+
import 'package:angular2/core.dart';
44

5-
import "toh/hero_list_component.dart" show HeroListComponent;
6-
import "wiki/wiki_component.dart" show WikiComponent;
7-
import "wiki/wiki_smart_component.dart" show WikiSmartComponent;
5+
import 'toh/hero_list_component.dart';
6+
import 'wiki/wiki_component.dart';
7+
import 'wiki/wiki_smart_component.dart';
88

99
@Component(
10-
selector: "my-app",
10+
selector: 'my-app',
1111
template: '''
1212
<hero-list></hero-list>
1313
<my-wiki></my-wiki>

public/docs/_examples/server-communication/dart/lib/toh/hero.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// #docregion
2+
int _toInt(id) => id is int ? id : int.parse(id);
3+
24
class Hero {
35
final int id;
46
final String name;
@@ -9,6 +11,4 @@ class Hero {
911
new Hero(_toInt(hero['id']), hero['name']);
1012

1113
Map toJson() => {'id': id, 'name': name};
12-
13-
static int _toInt(id) => id is int ? id : int.parse(id);
1414
}

public/docs/_examples/server-communication/dart/lib/toh/hero_service.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import 'dart:convert';
66
import 'hero.dart';
77
import 'package:angular2/core.dart';
88
import 'package:http/browser_client.dart';
9-
import 'package:http/http.dart' show Response;
9+
import 'package:http/http.dart';
1010

1111
@Injectable()
1212
class HeroService {
1313
// #docregion endpoint, http-get
14-
final String _heroesUrl = 'app/heroes'; // URL to web API
14+
static const _heroesUrl = 'app/heroes'; // URL to web API
1515
// #enddocregion endpoint, http-get
1616
final BrowserClient _http;
1717

@@ -35,7 +35,7 @@ class HeroService {
3535

3636
// #docregion addhero, addhero-sig
3737
Future<Hero> addHero(String name) async {
38-
// #enddocregion addhero-sig
38+
// #enddocregion addhero-sig
3939
try {
4040
final response = await _http.post(_heroesUrl,
4141
headers: {'Content-Type': 'application/json'},
@@ -50,8 +50,8 @@ class HeroService {
5050
// #docregion extract-data
5151
dynamic _extractData(Response res) {
5252
var body = JSON.decode(res.body);
53-
// TODO: once fixed, https://github.com/adaojunior/http-in-memory-web-api/issues/1
54-
// Drop the `?? body` term
53+
// TODO: https://github.com/adaojunior/http-in-memory-web-api/issues/1
54+
// Once #1 is fixed, drop the `?? body` term:
5555
return body['data'] ?? body;
5656
}
5757
// #enddocregion extract-data
@@ -69,6 +69,6 @@ class HeroService {
6969

7070
/*
7171
// #docregion endpoint-json
72-
private _heroesUrl = 'heroes.json'; // URL to JSON file
72+
static const _heroesUrl = 'heroes.json'; // URL to JSON file
7373
// #enddocregion endpoint-json
7474
*/

public/docs/_examples/server-communication/dart/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ transformers:
2323
resolved_identifiers:
2424
BrowserClient: 'package:http/browser_client.dart'
2525
- dart_to_js_script_rewriter
26-
# #enddocregion transformers

public/docs/_examples/server-communication/dart/web/main.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// #docplaster
22
// #docregion final
3-
import 'package:angular2/core.dart' show Provider;
3+
import 'package:angular2/core.dart';
44
// #docregion v1
5-
import 'package:angular2/platform/browser.dart' show bootstrap;
5+
import 'package:angular2/platform/browser.dart';
66
// #docregion http-providers
7-
import 'package:http/browser_client.dart' show BrowserClient;
7+
import 'package:http/browser_client.dart';
88
// #enddocregion http-providers
99

1010
import 'package:server_communication/app_component.dart';

public/docs/dart/latest/guide/_data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@
8080
},
8181

8282
"server-communication": {
83-
"title": "Http Client",
84-
"intro": "Talk to a remote server with the Angular Http Client."
83+
"title": "HTTP Client",
84+
"intro": "Talk to a remote server with an HTTP Client."
8585
},
8686

8787
"lifecycle-hooks": {

public/docs/dart/latest/guide/server-communication.jade

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ block includes
55
- var _Http = 'BrowserClient';
66
- var _Angular_Http = 'Dart <code>BrowserClient</code>'
77
- var _httpUrl = 'https://pub.dartlang.org/packages/http'
8-
- var _Angular_http_library = 'Dart <a href="!{_httpUrl}"><b>http</b> library</a>'
8+
- var _Angular_http_library = 'Dart <a href="' + _httpUrl + '"><b>http</b></a> library'
99

1010
block demos-list
11-
li HTTP client: Tour of Heroes
12-
li JSONP client: Wikipedia to fetch data from a service that doesn't support CORS (under development)
11+
li #[a(href="#http-client") HTTP client: Tour of Heroes]
12+
li #[a(href="#cors") JSONP client: Wikipedia to fetch data from a service that does not support CORS] #[b (under development)]
1313

1414
block rxjs-import
1515
//- N/A

public/docs/js/latest/guide/_data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@
8080
},
8181

8282
"server-communication": {
83-
"title": "Http Client",
84-
"intro": "Talk to a remote server with the Angular Http Client."
83+
"title": "HTTP Client",
84+
"intro": "Talk to a remote server with an HTTP Client."
8585
},
8686

8787
"lifecycle-hooks": {

public/docs/ts/latest/guide/_data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@
8080
},
8181

8282
"server-communication": {
83-
"title": "Http Client",
84-
"intro": "Talk to a remote server with the Angular Http Client."
83+
"title": "HTTP Client",
84+
"intro": "Talk to a remote server with an HTTP Client."
8585
},
8686

8787
"lifecycle-hooks": {

0 commit comments

Comments
 (0)