From dc6a066fed3444487a09105b08c055bc9fca9b71 Mon Sep 17 00:00:00 2001 From: gdi2290 Date: Tue, 20 Oct 2015 03:05:39 +0100 Subject: [PATCH] refactor(application): rename Binding into Provider while creating the server version I noticed bindings are still mentioned Closes #4951 --- modules/angular2/src/core/application.ts | 14 +++---- .../angular2/src/core/application_common.ts | 18 ++++---- modules/angular2/src/core/application_ref.ts | 42 +++++++++---------- .../angular2/src/core/application_tokens.ts | 2 +- .../web_workers/worker/application_common.ts | 6 +-- modules/angular2/test/public_api_spec.ts | 4 +- modules/upgrade/src/upgrade_adapter.ts | 8 ++-- 7 files changed, 47 insertions(+), 47 deletions(-) diff --git a/modules/angular2/src/core/application.ts b/modules/angular2/src/core/application.ts index 7c6383554f..65dea16a32 100644 --- a/modules/angular2/src/core/application.ts +++ b/modules/angular2/src/core/application.ts @@ -11,19 +11,19 @@ export {platform} from './application_common'; export { PlatformRef, ApplicationRef, - applicationCommonBindings, + applicationCommonProviders, createNgZone, platformCommon, - platformBindings + platformProviders } from './application_ref'; /// See [commonBootstrap] for detailed documentation. export function bootstrap(appComponentType: /*Type*/ any, - appBindings: Array = null): + appProviders: Array = null): Promise { - var bindings = [compilerProviders()]; - if (isPresent(appBindings)) { - bindings.push(appBindings); + var providers = [compilerProviders()]; + if (isPresent(appProviders)) { + providers.push(appProviders); } - return commonBootstrap(appComponentType, bindings); + return commonBootstrap(appComponentType, providers); } diff --git a/modules/angular2/src/core/application_common.ts b/modules/angular2/src/core/application_common.ts index 912a42f5a4..acfb60ab4b 100644 --- a/modules/angular2/src/core/application_common.ts +++ b/modules/angular2/src/core/application_common.ts @@ -38,13 +38,13 @@ import {EXCEPTION_PROVIDER} from './platform_bindings'; import {AnimationBuilder} from 'angular2/src/animate/animation_builder'; import {BrowserDetails} from 'angular2/src/animate/browser_details'; import {wtfInit} from './profile/wtf_init'; -import {platformCommon, PlatformRef, applicationCommonBindings} from './application_ref'; +import {platformCommon, PlatformRef, applicationCommonProviders} from './application_ref'; /** * A default set of providers which apply only to an Angular application running on * the UI thread. */ -export function applicationDomBindings(): Array { +export function applicationDomProviders(): Array { if (isBlank(DOM)) { throw "Must set a root DOM adapter first."; } @@ -77,7 +77,7 @@ export function applicationDomBindings(): Array { * If no providers are specified, `platform`'s behavior depends on whether an existing * platform exists: * - * If no platform exists, a new one will be created with the default {@link platformBindings}. + * If no platform exists, a new one will be created with the default {@link platformProviders}. * * If a platform already exists, it will be returned (regardless of what providers it * was created with). This is a convenience feature, allowing for multiple applications @@ -100,8 +100,8 @@ export function applicationDomBindings(): Array { * DOM access. Web-worker applications should call `platform` from * `src/web_workers/worker/application_common` instead. */ -export function platform(bindings?: Array): PlatformRef { - return platformCommon(bindings, () => { +export function platform(providers?: Array): PlatformRef { + return platformCommon(providers, () => { BrowserDomAdapter.makeCurrent(); wtfInit(); BrowserGetTestability.init(); @@ -219,12 +219,12 @@ export function platform(bindings?: Array): PlatformRef * Returns a `Promise` of {@link ComponentRef}. */ export function commonBootstrap(appComponentType: /*Type*/ any, - appBindings: Array = null): + appProviders: Array = null): Promise { var p = platform(); - var bindings = [applicationCommonBindings(), applicationDomBindings()]; - if (isPresent(appBindings)) { - bindings.push(appBindings); + var bindings = [applicationCommonProviders(), applicationDomProviders()]; + if (isPresent(appProviders)) { + bindings.push(appProviders); } return p.application(bindings).bootstrap(appComponentType); } diff --git a/modules/angular2/src/core/application_ref.ts b/modules/angular2/src/core/application_ref.ts index 8946c2f941..8d134c8d78 100644 --- a/modules/angular2/src/core/application_ref.ts +++ b/modules/angular2/src/core/application_ref.ts @@ -49,7 +49,7 @@ import {Compiler_} from "./linker/compiler"; * These are providers that should be singletons shared among all Angular applications * running on the page. */ -export function platformBindings(): Array { +export function platformProviders(): Array { return [provide(Reflector, {useValue: reflector}), TestabilityRegistry]; } @@ -62,7 +62,7 @@ function _componentProviders(appComponentType: Type): Array { - // TODO(rado): investigate whether to support bindings on root component. + // TODO(rado): investigate whether to support providers on root component. return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector) .then((componentRef) => { if (isPresent(componentRef.location.nativeElement)) { @@ -87,7 +87,7 @@ function _componentProviders(appComponentType: Type): Array { +export function applicationCommonProviders(): Array { return [ provide(Compiler, {useClass: Compiler_}), APP_ID_RANDOM_PROVIDER, @@ -121,10 +121,10 @@ export function createNgZone(): NgZone { var _platform: PlatformRef; -export function platformCommon(bindings?: Array, initializer?: () => void): - PlatformRef { +export function platformCommon(providers?: Array, + initializer?: () => void): PlatformRef { if (isPresent(_platform)) { - if (isBlank(bindings)) { + if (isBlank(providers)) { return _platform; } throw "platform() can only be called once per page"; @@ -134,10 +134,10 @@ export function platformCommon(bindings?: Array, initia initializer(); } - if (isBlank(bindings)) { - bindings = platformBindings(); + if (isBlank(providers)) { + providers = platformProviders(); } - _platform = new PlatformRef_(Injector.resolveAndCreate(bindings), () => { _platform = null; }); + _platform = new PlatformRef_(Injector.resolveAndCreate(providers), () => { _platform = null; }); return _platform; } @@ -170,7 +170,7 @@ export abstract class PlatformRef { * renderer, and other framework components. An application hosts one or more * root components, which can be initialized via `ApplicationRef.bootstrap()`. * - *##Application Bindings + *##Application Providers * * Angular applications require numerous providers to be properly instantiated. * When using `application()` to create a new app on the page, these providers @@ -179,17 +179,17 @@ export abstract class PlatformRef { * * ### Example * ``` - * var myAppBindings = [MyAppService]; + * var myAppProviders = [MyAppService]; * * platform() - * .application([applicationCommonBindings(), applicationDomBindings(), myAppBindings]) + * .application([applicationCommonProviders(), applicationDomProviders(), myAppProviders]) * .bootstrap(MyTopLevelComponent); * ``` *##See Also * * See the {@link bootstrap} documentation for more details. */ - abstract application(bindings: Array): ApplicationRef; + abstract application(providers: Array): ApplicationRef; /** * Instantiate a new Angular application on the page, using providers which @@ -223,8 +223,8 @@ export class PlatformRef_ extends PlatformRef { get injector(): Injector { return this._injector; } - application(bindings: Array): ApplicationRef { - var app = this._initApp(createNgZone(), bindings); + application(providers: Array): ApplicationRef { + var app = this._initApp(createNgZone(), providers); return app; } @@ -233,8 +233,8 @@ export class PlatformRef_ extends PlatformRef { var zone = createNgZone(); var completer = PromiseWrapper.completer(); zone.run(() => { - PromiseWrapper.then(bindingFn(zone), (bindings: Array) => { - completer.resolve(this._initApp(zone, bindings)); + PromiseWrapper.then(bindingFn(zone), (providers: Array) => { + completer.resolve(this._initApp(zone, providers)); }); }); return completer.promise; @@ -301,20 +301,20 @@ export abstract class ApplicationRef { * specified application component onto DOM elements identified by the [componentType]'s * selector and kicks off automatic change detection to finish initializing the component. * - *##Optional Bindings + *##Optional Providers * - * Bindings for the given component can optionally be overridden via the `providers` + * Providers for the given component can optionally be overridden via the `providers` * parameter. These providers will only apply for the root component being added and any * child components under it. * * ### Example * ``` - * var app = platform.application([applicationCommonBindings(), applicationDomBindings()]; + * var app = platform.application([applicationCommonProviders(), applicationDomProviders()]; * app.bootstrap(FirstRootComponent); * app.bootstrap(SecondRootComponent, [provide(OverrideBinding, {useClass: OverriddenBinding})]); * ``` */ - abstract bootstrap(componentType: Type, bindings?: Array): + abstract bootstrap(componentType: Type, providers?: Array): Promise; /** diff --git a/modules/angular2/src/core/application_tokens.ts b/modules/angular2/src/core/application_tokens.ts index 23f15ca169..226e915307 100644 --- a/modules/angular2/src/core/application_tokens.ts +++ b/modules/angular2/src/core/application_tokens.ts @@ -40,7 +40,7 @@ function _appIdRandomProviderFactory() { } /** - * Bindings that will generate a random APP_ID_TOKEN. + * Providers that will generate a random APP_ID_TOKEN. */ export const APP_ID_RANDOM_PROVIDER: Provider = CONST_EXPR(new Provider(APP_ID, {useFactory: _appIdRandomProviderFactory, deps: []})); diff --git a/modules/angular2/src/web_workers/worker/application_common.ts b/modules/angular2/src/web_workers/worker/application_common.ts index 717f44b0c7..ab72557212 100644 --- a/modules/angular2/src/web_workers/worker/application_common.ts +++ b/modules/angular2/src/web_workers/worker/application_common.ts @@ -29,7 +29,7 @@ import { platformCommon, PlatformRef, ApplicationRef, - applicationCommonBindings + applicationCommonProviders } from 'angular2/src/core/application_ref'; import {Serializer} from "angular2/src/web_workers/shared/serializer"; import {ON_WEB_WORKER} from "angular2/src/web_workers/shared/api"; @@ -56,7 +56,7 @@ import {compilerProviders} from 'angular2/src/core/compiler/compiler'; * If no providers are specified, `platform`'s behavior depends on whether an existing * platform exists: * - * If no platform exists, a new one will be created with the default {@link platformBindings}. + * If no platform exists, a new one will be created with the default {@link platformProviders}. * * If a platform already exists, it will be returned (regardless of what providers it * was created with). This is a convenience feature, allowing for multiple applications @@ -129,7 +129,7 @@ export function bootstrapWebWorkerCommon(appComponentType: Type, bus: MessageBus var emitter = bus.from(SETUP_CHANNEL); subscription = ObservableWrapper.subscribe(emitter, (message: {[key: string]: any}) => { var bindings = - [applicationCommonBindings(), webWorkerProviders(appComponentType, bus, message)]; + [applicationCommonProviders(), webWorkerProviders(appComponentType, bus, message)]; if (isPresent(appProviders)) { bindings.push(appProviders); } diff --git a/modules/angular2/test/public_api_spec.ts b/modules/angular2/test/public_api_spec.ts index 8d5254c13b..7b7d3db164 100644 --- a/modules/angular2/test/public_api_spec.ts +++ b/modules/angular2/test/public_api_spec.ts @@ -1142,7 +1142,7 @@ var NG_API = [ 'WrappedValue.wrapped=', 'WtfScopeFn:dart', 'ZeroArgFunction:dart', - 'applicationCommonBindings()', + 'applicationCommonProviders()', 'asNativeElements()', 'bind()', 'provide()', @@ -1152,7 +1152,7 @@ var NG_API = [ 'inspectElement()', 'inspectNativeElement()', 'platform():js', - 'platformBindings()', + 'platformProviders()', 'platformCommon()', 'resolveForwardRef():js', 'wtfCreateScope():js', diff --git a/modules/upgrade/src/upgrade_adapter.ts b/modules/upgrade/src/upgrade_adapter.ts index b52a8178f1..d96d462de7 100644 --- a/modules/upgrade/src/upgrade_adapter.ts +++ b/modules/upgrade/src/upgrade_adapter.ts @@ -15,8 +15,8 @@ import { Provider, Type } from 'angular2/angular2'; -import {applicationDomBindings} from 'angular2/src/core/application_common'; -import {applicationCommonBindings} from 'angular2/src/core/application_ref'; +import {applicationDomProviders} from 'angular2/src/core/application_common'; +import {applicationCommonProviders} from 'angular2/src/core/application_ref'; import {compilerProviders} from 'angular2/src/core/compiler/compiler'; import {getComponentInfo, ComponentInfo} from './metadata'; @@ -298,8 +298,8 @@ export class UpgradeAdapter { var ng1Injector: angular.auto.IInjectorService = null; var platformRef: PlatformRef = platform(); var applicationRef: ApplicationRef = platformRef.application([ - applicationCommonBindings(), - applicationDomBindings(), + applicationCommonProviders(), + applicationDomProviders(), compilerProviders(), provide(NG1_INJECTOR, {useFactory: () => ng1Injector}), provide(NG1_COMPILE, {useFactory: () => ng1Injector.get(NG1_COMPILE)}),