From 29511831cdbf44f784cb2de6829de1769f00810a Mon Sep 17 00:00:00 2001 From: Ward Bell Date: Tue, 17 May 2016 21:25:41 -0700 Subject: [PATCH] docs(server-communication): heavily refactored (TS & Dart) --- .../dart/example-config.json | 0 .../dart/lib/app_component.dart | 31 +++ .../dart/lib/hero_data.dart | 4 +- .../dart/lib/toh/hero_list_component.dart | 2 +- .../dart/lib/toh/hero_list_component.html | 1 + .../dart/lib/toh/hero_service.dart | 3 + .../dart/lib/toh/toh_component.dart | 36 --- .../server-communication/dart/pubspec.yaml | 8 +- .../server-communication/dart/web/index.html | 5 +- .../server-communication/dart/web/main.dart | 40 ++- .../server-communication/dart/web/sample.css | 1 + .../server-communication/e2e-spec.js | 87 +++---- .../ts/app/add-rxjs-operators.ts | 9 - .../ts/app/app.component.ts | 37 +++ .../server-communication/ts/app/main.ts | 41 +-- .../ts/app/rxjs-operators.ts | 16 ++ .../ts/app/toh/hero-list.component.html | 1 + ...nt.1.ts => hero-list.component.promise.ts} | 11 +- .../ts/app/toh/hero-list.component.ts | 7 +- ...o.service.1.ts => hero.service.promise.ts} | 6 +- .../ts/app/toh/hero.service.ts | 6 +- .../server-communication/ts/app/toh/hero.ts | 4 +- .../ts/app/toh/toh.component.ts | 43 ---- .../server-communication/ts/index.html | 6 +- .../server-communication/ts/sample.css | 1 + .../latest/guide/server-communication.jade | 57 +++-- .../ts/latest/guide/server-communication.jade | 235 ++++++++++-------- 27 files changed, 391 insertions(+), 307 deletions(-) create mode 100644 public/docs/_examples/server-communication/dart/example-config.json create mode 100644 public/docs/_examples/server-communication/dart/lib/app_component.dart delete mode 100644 public/docs/_examples/server-communication/dart/lib/toh/toh_component.dart create mode 100644 public/docs/_examples/server-communication/dart/web/sample.css delete mode 100644 public/docs/_examples/server-communication/ts/app/add-rxjs-operators.ts create mode 100644 public/docs/_examples/server-communication/ts/app/app.component.ts create mode 100644 public/docs/_examples/server-communication/ts/app/rxjs-operators.ts rename public/docs/_examples/server-communication/ts/app/toh/{hero-list.component.1.ts => hero-list.component.promise.ts} (79%) rename public/docs/_examples/server-communication/ts/app/toh/{hero.service.1.ts => hero.service.promise.ts} (90%) delete mode 100644 public/docs/_examples/server-communication/ts/app/toh/toh.component.ts create mode 100644 public/docs/_examples/server-communication/ts/sample.css diff --git a/public/docs/_examples/server-communication/dart/example-config.json b/public/docs/_examples/server-communication/dart/example-config.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/docs/_examples/server-communication/dart/lib/app_component.dart b/public/docs/_examples/server-communication/dart/lib/app_component.dart new file mode 100644 index 0000000000..55c91e6e4d --- /dev/null +++ b/public/docs/_examples/server-communication/dart/lib/app_component.dart @@ -0,0 +1,31 @@ +// #docplaster +// #docregion +import "package:angular2/core.dart" show Component; + +import "toh/hero_list_component.dart" show HeroListComponent; +import "wiki/wiki_component.dart" show WikiComponent; +import "wiki/wiki_smart_component.dart" show WikiSmartComponent; + +@Component( + selector: "my-app", + template: ''' + + + + ''', + // #enddocregion + /* + // #docregion http-providers + providers: const [ + // in-memory web api provider + const Provider(BrowserClient, + useFactory: HttpClientBackendServiceFactory, deps: const [])], + // #enddocregion http-providers + */ + // #docregion + directives: const [ + HeroListComponent, + WikiComponent, + WikiSmartComponent + ]) +class AppComponent {} diff --git a/public/docs/_examples/server-communication/dart/lib/hero_data.dart b/public/docs/_examples/server-communication/dart/lib/hero_data.dart index 50ec0fab1d..ae0480b98d 100644 --- a/public/docs/_examples/server-communication/dart/lib/hero_data.dart +++ b/public/docs/_examples/server-communication/dart/lib/hero_data.dart @@ -2,7 +2,7 @@ import 'package:http/browser_client.dart'; import 'package:http_in_memory_web_api/http_in_memory_web_api.dart'; -CreateDb createDb = () => { +CreateDb _createDb = () => { 'heroes': [ {"id": "1", "name": "Windstorm"}, {"id": "2", "name": "Bombasto"}, @@ -12,4 +12,4 @@ CreateDb createDb = () => { }; BrowserClient HttpClientBackendServiceFactory() => - new HttpClientInMemoryBackendService(createDb); + new HttpClientInMemoryBackendService(_createDb); diff --git a/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.dart b/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.dart index 58fe0bb40c..23e1d6e9d7 100644 --- a/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.dart +++ b/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.dart @@ -9,7 +9,7 @@ import 'hero_service.dart'; @Component( selector: 'hero-list', templateUrl: 'hero_list_component.html', - styles: const ['.error {color:red;}']) + providers: const [HeroService]) // #docregion component class HeroListComponent implements OnInit { final HeroService _heroService; diff --git a/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.html b/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.html index 86e2deedd6..297ffaa6c6 100644 --- a/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.html +++ b/public/docs/_examples/server-communication/dart/lib/toh/hero_list_component.html @@ -1,4 +1,5 @@ +

Tour of Heroes

Heroes: