refactor(application): rename Binding into Provider

while creating the server version I noticed bindings are still
mentioned

Closes #4951
This commit is contained in:
gdi2290 2015-10-20 03:05:39 +01:00 committed by Victor Berchet
parent ac52bfd80f
commit dc6a066fed
7 changed files with 47 additions and 47 deletions

View File

@ -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<Type | Provider | any[]> = null):
appProviders: Array<Type | Provider | any[]> = null):
Promise<ComponentRef> {
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);
}

View File

@ -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<Type | Provider | any[]> {
export function applicationDomProviders(): Array<Type | Provider | any[]> {
if (isBlank(DOM)) {
throw "Must set a root DOM adapter first.";
}
@ -77,7 +77,7 @@ export function applicationDomBindings(): Array<Type | Provider | any[]> {
* 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<Type | Provider | any[]> {
* DOM access. Web-worker applications should call `platform` from
* `src/web_workers/worker/application_common` instead.
*/
export function platform(bindings?: Array<Type | Provider | any[]>): PlatformRef {
return platformCommon(bindings, () => {
export function platform(providers?: Array<Type | Provider | any[]>): PlatformRef {
return platformCommon(providers, () => {
BrowserDomAdapter.makeCurrent();
wtfInit();
BrowserGetTestability.init();
@ -219,12 +219,12 @@ export function platform(bindings?: Array<Type | Provider | any[]>): PlatformRef
* Returns a `Promise` of {@link ComponentRef}.
*/
export function commonBootstrap(appComponentType: /*Type*/ any,
appBindings: Array<Type | Provider | any[]> = null):
appProviders: Array<Type | Provider | any[]> = null):
Promise<ComponentRef> {
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);
}

View File

@ -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<Type | Provider | any[]> {
export function platformProviders(): Array<Type | Provider | any[]> {
return [provide(Reflector, {useValue: reflector}), TestabilityRegistry];
}
@ -62,7 +62,7 @@ function _componentProviders(appComponentType: Type): Array<Type | Provider | an
provide(APP_COMPONENT_REF_PROMISE,
{
useFactory: (dynamicComponentLoader, injector: Injector) => {
// 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<Type | Provider | an
* Construct a default set of providers which should be included in any Angular
* application, regardless of whether it runs on the UI thread or in a web worker.
*/
export function applicationCommonBindings(): Array<Type | Provider | any[]> {
export function applicationCommonProviders(): Array<Type | Provider | any[]> {
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<Type | Provider | any[]>, initializer?: () => void):
PlatformRef {
export function platformCommon(providers?: Array<Type | Provider | any[]>,
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<Type | Provider | any[]>, 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<Type | Provider | any[]>): ApplicationRef;
abstract application(providers: Array<Type | Provider | any[]>): 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<Type | Provider | any[]>): ApplicationRef {
var app = this._initApp(createNgZone(), bindings);
application(providers: Array<Type | Provider | any[]>): 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<Type | Provider | any[]>) => {
completer.resolve(this._initApp(zone, bindings));
PromiseWrapper.then(bindingFn(zone), (providers: Array<Type | Provider | any[]>) => {
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<Type | Provider | any[]>):
abstract bootstrap(componentType: Type, providers?: Array<Type | Provider | any[]>):
Promise<ComponentRef>;
/**

View File

@ -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: []}));

View File

@ -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);
}

View File

@ -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',

View File

@ -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)}),