From dd3e6271c259d1fb3e150a4a43bf2f3dac1413e8 Mon Sep 17 00:00:00 2001 From: Rado Kirov Date: Wed, 11 Mar 2015 16:48:57 -0700 Subject: [PATCH] chore(services): rename services. Closes #711 --- modules/angular2/docs/core/02_directives.md | 4 +-- .../src/core/annotations/annotations.js | 25 +++---------------- modules/angular2/src/core/application.js | 4 +-- .../proto_element_injector_builder.js | 3 --- modules/angular2/src/core/compiler/view.js | 2 +- .../test/core/compiler/integration_spec.js | 4 +-- .../proto_element_injector_builder_spec.js | 2 +- .../angular2/test/core/compiler/view_spec.js | 2 +- .../integration/basic_bind_files/bar.dart | 2 +- .../basic_bind_files/expected/bar.ngDeps.dart | 2 +- .../integration/chained_deps_files/bar.dart | 2 +- .../expected/bar.ngDeps.dart | 2 +- .../integration/list_of_types_files/bar.dart | 2 +- .../expected/bar.ngDeps.dart | 2 +- .../examples/src/hello_world/index_common.js | 2 +- .../examples/src/hello_world/index_static.js | 2 +- tools/transpiler/spec/types_spec.js | 1 - 17 files changed, 20 insertions(+), 43 deletions(-) diff --git a/modules/angular2/docs/core/02_directives.md b/modules/angular2/docs/core/02_directives.md index fa7d34315b..fac5878369 100644 --- a/modules/angular2/docs/core/02_directives.md +++ b/modules/angular2/docs/core/02_directives.md @@ -220,7 +220,7 @@ To better understand the kinds of injections which are supported in Angular we h ### Injecting Services -Service injection is the most straight forward kind of injection which Angular supports. It involves a component configuring the `componentServices` and then letting the directive ask for the configured service. +Service injection is the most straight forward kind of injection which Angular supports. It involves a component configuring the `services` and then letting the directive ask for the configured service. This example illustrates how to inject `MyService` into `House` directive. @@ -231,7 +231,7 @@ class MyService {} | Assume a service which needs to be inject | @Component({ | Assume a top level application component which selector: 'my-app', | configures the services to be injected. - componentServices: [MyService] | + services: [MyService] | }) | @Template({ | Assume we have a template that needs to be url: 'my_app.html', | configured with directives to be injected. diff --git a/modules/angular2/src/core/annotations/annotations.js b/modules/angular2/src/core/annotations/annotations.js index eb31368ada..20858dc7b3 100644 --- a/modules/angular2/src/core/annotations/annotations.js +++ b/modules/angular2/src/core/annotations/annotations.js @@ -5,7 +5,6 @@ import {ListWrapper, List} from 'angular2/src/facade/collection'; export class Directive { selector:any; //string; bind:any; - lightDomServices:any; //List; implementsTypes:any; //List; lifecycle:any; //List events:any; //List @@ -14,20 +13,17 @@ export class Directive { selector, bind, events, - lightDomServices, implementsTypes, lifecycle }:{ selector:string, bind:any, events: any, - lightDomServices:List, implementsTypes:List, lifecycle:List }={}) { this.selector = selector; - this.lightDomServices = lightDomServices; this.implementsTypes = implementsTypes; this.bind = bind; this.events = events; @@ -41,26 +37,21 @@ export class Directive { export class Component extends Directive { //TODO: vsavkin: uncomment it once the issue with defining fields in a sublass works - shadowDomServices:any; //List; - componentServices:any; //List; + services:any; //List; @CONST() constructor({ selector, bind, events, - lightDomServices, - shadowDomServices, - componentServices, + services, implementsTypes, lifecycle }:{ selector:String, bind:Object, events:Object, - lightDomServices:List, - shadowDomServices:List, - componentServices:List, + services:List, implementsTypes:List, lifecycle:List }={}) @@ -69,13 +60,11 @@ export class Component extends Directive { selector: selector, bind: bind, events: events, - lightDomServices: lightDomServices, implementsTypes: implementsTypes, lifecycle: lifecycle }); - this.shadowDomServices = shadowDomServices; - this.componentServices = componentServices; + this.services = services; } } @@ -86,7 +75,6 @@ export class Decorator extends Directive { selector, bind, events, - lightDomServices, implementsTypes, lifecycle, compileChildren = true, @@ -94,7 +82,6 @@ export class Decorator extends Directive { selector:string, bind:any, events:any, - lightDomServices:List, implementsTypes:List, lifecycle:List, compileChildren:boolean @@ -105,7 +92,6 @@ export class Decorator extends Directive { selector: selector, bind: bind, events: events, - lightDomServices: lightDomServices, implementsTypes: implementsTypes, lifecycle: lifecycle }); @@ -118,13 +104,11 @@ export class Viewport extends Directive { selector, bind, events, - lightDomServices, implementsTypes, lifecycle }:{ selector:string, bind:any, - lightDomServices:List, implementsTypes:List, lifecycle:List }={}) @@ -133,7 +117,6 @@ export class Viewport extends Directive { selector: selector, bind: bind, events: events, - lightDomServices: lightDomServices, implementsTypes: implementsTypes, lifecycle: lifecycle }); diff --git a/modules/angular2/src/core/application.js b/modules/angular2/src/core/application.js index 137b830e8f..2601bbfb65 100644 --- a/modules/angular2/src/core/application.js +++ b/modules/angular2/src/core/application.js @@ -43,9 +43,7 @@ function _injectorBindings(appComponentType): List { return [ bind(appDocumentToken).toValue(DOM.defaultDoc()), bind(appComponentAnnotatedTypeToken).toFactory((reader) => { - // TODO(rado): inspect annotation here and warn if there are bindings, - // lightDomServices, and other component annotations that are skipped - // for bootstrapping components. + // TODO(rado): investigate whether to support bindings on root component. return reader.read(appComponentType); }, [DirectiveMetadataReader]), diff --git a/modules/angular2/src/core/compiler/pipeline/proto_element_injector_builder.js b/modules/angular2/src/core/compiler/pipeline/proto_element_injector_builder.js index c58599995f..b452fe3496 100644 --- a/modules/angular2/src/core/compiler/pipeline/proto_element_injector_builder.js +++ b/modules/angular2/src/core/compiler/pipeline/proto_element_injector_builder.js @@ -34,9 +34,6 @@ export class ProtoElementInjectorBuilder extends CompileStep { var distanceToParentInjector = this._getDistanceToParentInjector(parent, current); var parentProtoElementInjector = this._getParentProtoElementInjector(parent, current); var injectorBindings = ListWrapper.map(current.getAllDirectives(), this._createBinding); - // TODO: add lightDomServices as well, - // but after the directives as we rely on that order - // in the element_binder_builder. // Create a protoElementInjector for any element that either has bindings *or* has one // or more var- defined. Elements with a var- defined need a their own element injector diff --git a/modules/angular2/src/core/compiler/view.js b/modules/angular2/src/core/compiler/view.js index 0a9e34ca2d..a510e8fc88 100644 --- a/modules/angular2/src/core/compiler/view.js +++ b/modules/angular2/src/core/compiler/view.js @@ -144,7 +144,7 @@ export class View { // shadowDomAppInjector if (isPresent(componentDirective)) { - var services = componentDirective.annotation.componentServices; + var services = componentDirective.annotation.services; if (isPresent(services)) shadowDomAppInjector = appInjector.createChild(services); else { diff --git a/modules/angular2/test/core/compiler/integration_spec.js b/modules/angular2/test/core/compiler/integration_spec.js index c39ddab401..c1b1651da0 100644 --- a/modules/angular2/test/core/compiler/integration_spec.js +++ b/modules/angular2/test/core/compiler/integration_spec.js @@ -585,7 +585,7 @@ class ComponentWithPipes { @Component({ selector: 'child-cmp', - componentServices: [MyService] + services: [MyService] }) @Template({ directives: [MyDir], @@ -635,7 +635,7 @@ class CompWithAncestor { @Component({ selector: '[child-cmp2]', - componentServices: [MyService] + services: [MyService] }) class ChildComp2 { ctxProp:string; diff --git a/modules/angular2/test/core/compiler/pipeline/proto_element_injector_builder_spec.js b/modules/angular2/test/core/compiler/pipeline/proto_element_injector_builder_spec.js index 6426cfb302..0a793b2cfe 100644 --- a/modules/angular2/test/core/compiler/pipeline/proto_element_injector_builder_spec.js +++ b/modules/angular2/test/core/compiler/pipeline/proto_element_injector_builder_spec.js @@ -209,7 +209,7 @@ class SomeComponentService {} class SomeViewportDirective {} @Component({ - componentServices: [SomeComponentService] + services: [SomeComponentService] }) class SomeComponentDirective {} diff --git a/modules/angular2/test/core/compiler/view_spec.js b/modules/angular2/test/core/compiler/view_spec.js index e4eac84a7d..1ef3ff5cf3 100644 --- a/modules/angular2/test/core/compiler/view_spec.js +++ b/modules/angular2/test/core/compiler/view_spec.js @@ -676,7 +676,7 @@ class DirectiveImplementingOnChange { class SomeService {} -@Component({componentServices: [SomeService]}) +@Component({services: [SomeService]}) class SomeComponent { service: SomeService; constructor(service: SomeService) { diff --git a/modules/angular2/test/transform/integration/basic_bind_files/bar.dart b/modules/angular2/test/transform/integration/basic_bind_files/bar.dart index 6c9c91fdaa..62f77c23a5 100644 --- a/modules/angular2/test/transform/integration/basic_bind_files/bar.dart +++ b/modules/angular2/test/transform/integration/basic_bind_files/bar.dart @@ -2,7 +2,7 @@ library bar; import 'package:angular2/src/core/annotations/annotations.dart'; -@Component(selector: 'soup', componentServices: const [ToolTip]) +@Component(selector: 'soup', services: const [ToolTip]) class MyComponent {} @Decorator(selector: '[tool-tip]', bind: const {'text': 'tool-tip'}) diff --git a/modules/angular2/test/transform/integration/basic_bind_files/expected/bar.ngDeps.dart b/modules/angular2/test/transform/integration/basic_bind_files/expected/bar.ngDeps.dart index aebd3e9ff4..3c99b26677 100644 --- a/modules/angular2/test/transform/integration/basic_bind_files/expected/bar.ngDeps.dart +++ b/modules/angular2/test/transform/integration/basic_bind_files/expected/bar.ngDeps.dart @@ -12,7 +12,7 @@ void setupReflection(reflector) { "factory": () => new MyComponent(), "parameters": const [], "annotations": const [ - const Component(selector: 'soup', componentServices: const [ToolTip]) + const Component(selector: 'soup', services: const [ToolTip]) ] }) ..registerType(ToolTip, { diff --git a/modules/angular2/test/transform/integration/chained_deps_files/bar.dart b/modules/angular2/test/transform/integration/chained_deps_files/bar.dart index 86f00a1b8d..3bbd3bb2f4 100644 --- a/modules/angular2/test/transform/integration/chained_deps_files/bar.dart +++ b/modules/angular2/test/transform/integration/chained_deps_files/bar.dart @@ -4,7 +4,7 @@ import 'package:angular2/src/core/annotations/annotations.dart'; import 'foo.dart' as dep; @Component( - selector: '[soup]', componentServices: const [dep.DependencyComponent]) + selector: '[soup]', services: const [dep.DependencyComponent]) class MyComponent { MyComponent(); } diff --git a/modules/angular2/test/transform/integration/chained_deps_files/expected/bar.ngDeps.dart b/modules/angular2/test/transform/integration/chained_deps_files/expected/bar.ngDeps.dart index 004daf4f17..6033870b71 100644 --- a/modules/angular2/test/transform/integration/chained_deps_files/expected/bar.ngDeps.dart +++ b/modules/angular2/test/transform/integration/chained_deps_files/expected/bar.ngDeps.dart @@ -16,7 +16,7 @@ void setupReflection(reflector) { "annotations": const [ const Component( selector: '[soup]', - componentServices: const [dep.DependencyComponent]) + services: const [dep.DependencyComponent]) ] }); i0.setupReflection(reflector); diff --git a/modules/angular2/test/transform/integration/list_of_types_files/bar.dart b/modules/angular2/test/transform/integration/list_of_types_files/bar.dart index 2d242c1396..e8cf596129 100644 --- a/modules/angular2/test/transform/integration/list_of_types_files/bar.dart +++ b/modules/angular2/test/transform/integration/list_of_types_files/bar.dart @@ -3,7 +3,7 @@ library bar; import 'package:angular2/src/core/annotations/annotations.dart'; import 'foo.dart'; -@Component(componentServices: const [MyContext]) +@Component(services: const [MyContext]) class MyComponent { final MyContext c; MyComponent(this.c); diff --git a/modules/angular2/test/transform/integration/list_of_types_files/expected/bar.ngDeps.dart b/modules/angular2/test/transform/integration/list_of_types_files/expected/bar.ngDeps.dart index 7314f4c639..7fbc8e1ef8 100644 --- a/modules/angular2/test/transform/integration/list_of_types_files/expected/bar.ngDeps.dart +++ b/modules/angular2/test/transform/integration/list_of_types_files/expected/bar.ngDeps.dart @@ -13,7 +13,7 @@ void setupReflection(reflector) { "factory": (MyContext c) => new MyComponent(c), "parameters": const [const [MyContext]], "annotations": const [ - const Component(componentServices: const [MyContext]) + const Component(services: const [MyContext]) ] }); } diff --git a/modules/examples/src/hello_world/index_common.js b/modules/examples/src/hello_world/index_common.js index 3ed4672da7..b02f461163 100644 --- a/modules/examples/src/hello_world/index_common.js +++ b/modules/examples/src/hello_world/index_common.js @@ -15,7 +15,7 @@ import {bootstrap, Component, Decorator, Template, NgElement} from 'angular2/ang selector: 'hello-app', // These are services that would be created if a class in the component's // template tries to inject them. - componentServices: [GreetingService] + services: [GreetingService] }) // The template for the component. @Template({ diff --git a/modules/examples/src/hello_world/index_static.js b/modules/examples/src/hello_world/index_static.js index c4f198efe0..0cf128464d 100644 --- a/modules/examples/src/hello_world/index_static.js +++ b/modules/examples/src/hello_world/index_static.js @@ -29,7 +29,7 @@ function setup() { "annotations" : [ new Component({ selector: 'hello-app', - componentServices: [app.GreetingService] + services: [app.GreetingService] }), new Template({ directives: [app.RedDec], diff --git a/tools/transpiler/spec/types_spec.js b/tools/transpiler/spec/types_spec.js index 0facc5751e..4a13028e75 100644 --- a/tools/transpiler/spec/types_spec.js +++ b/tools/transpiler/spec/types_spec.js @@ -22,7 +22,6 @@ function namedObjectType({a,b}:{a:A,b:B}) { class Bar { constructor({ selector, - lightDomServices, implementsTypes }) {