refactor(application): rename Binding into Provider
while creating the server version I noticed bindings are still mentioned Closes #4951
This commit is contained in:
parent
ac52bfd80f
commit
dc6a066fed
|
@ -11,19 +11,19 @@ export {platform} from './application_common';
|
||||||
export {
|
export {
|
||||||
PlatformRef,
|
PlatformRef,
|
||||||
ApplicationRef,
|
ApplicationRef,
|
||||||
applicationCommonBindings,
|
applicationCommonProviders,
|
||||||
createNgZone,
|
createNgZone,
|
||||||
platformCommon,
|
platformCommon,
|
||||||
platformBindings
|
platformProviders
|
||||||
} from './application_ref';
|
} from './application_ref';
|
||||||
|
|
||||||
/// See [commonBootstrap] for detailed documentation.
|
/// See [commonBootstrap] for detailed documentation.
|
||||||
export function bootstrap(appComponentType: /*Type*/ any,
|
export function bootstrap(appComponentType: /*Type*/ any,
|
||||||
appBindings: Array<Type | Provider | any[]> = null):
|
appProviders: Array<Type | Provider | any[]> = null):
|
||||||
Promise<ComponentRef> {
|
Promise<ComponentRef> {
|
||||||
var bindings = [compilerProviders()];
|
var providers = [compilerProviders()];
|
||||||
if (isPresent(appBindings)) {
|
if (isPresent(appProviders)) {
|
||||||
bindings.push(appBindings);
|
providers.push(appProviders);
|
||||||
}
|
}
|
||||||
return commonBootstrap(appComponentType, bindings);
|
return commonBootstrap(appComponentType, providers);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,13 +38,13 @@ import {EXCEPTION_PROVIDER} from './platform_bindings';
|
||||||
import {AnimationBuilder} from 'angular2/src/animate/animation_builder';
|
import {AnimationBuilder} from 'angular2/src/animate/animation_builder';
|
||||||
import {BrowserDetails} from 'angular2/src/animate/browser_details';
|
import {BrowserDetails} from 'angular2/src/animate/browser_details';
|
||||||
import {wtfInit} from './profile/wtf_init';
|
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
|
* A default set of providers which apply only to an Angular application running on
|
||||||
* the UI thread.
|
* the UI thread.
|
||||||
*/
|
*/
|
||||||
export function applicationDomBindings(): Array<Type | Provider | any[]> {
|
export function applicationDomProviders(): Array<Type | Provider | any[]> {
|
||||||
if (isBlank(DOM)) {
|
if (isBlank(DOM)) {
|
||||||
throw "Must set a root DOM adapter first.";
|
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
|
* If no providers are specified, `platform`'s behavior depends on whether an existing
|
||||||
* platform exists:
|
* 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
|
* 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
|
* 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
|
* DOM access. Web-worker applications should call `platform` from
|
||||||
* `src/web_workers/worker/application_common` instead.
|
* `src/web_workers/worker/application_common` instead.
|
||||||
*/
|
*/
|
||||||
export function platform(bindings?: Array<Type | Provider | any[]>): PlatformRef {
|
export function platform(providers?: Array<Type | Provider | any[]>): PlatformRef {
|
||||||
return platformCommon(bindings, () => {
|
return platformCommon(providers, () => {
|
||||||
BrowserDomAdapter.makeCurrent();
|
BrowserDomAdapter.makeCurrent();
|
||||||
wtfInit();
|
wtfInit();
|
||||||
BrowserGetTestability.init();
|
BrowserGetTestability.init();
|
||||||
|
@ -219,12 +219,12 @@ export function platform(bindings?: Array<Type | Provider | any[]>): PlatformRef
|
||||||
* Returns a `Promise` of {@link ComponentRef}.
|
* Returns a `Promise` of {@link ComponentRef}.
|
||||||
*/
|
*/
|
||||||
export function commonBootstrap(appComponentType: /*Type*/ any,
|
export function commonBootstrap(appComponentType: /*Type*/ any,
|
||||||
appBindings: Array<Type | Provider | any[]> = null):
|
appProviders: Array<Type | Provider | any[]> = null):
|
||||||
Promise<ComponentRef> {
|
Promise<ComponentRef> {
|
||||||
var p = platform();
|
var p = platform();
|
||||||
var bindings = [applicationCommonBindings(), applicationDomBindings()];
|
var bindings = [applicationCommonProviders(), applicationDomProviders()];
|
||||||
if (isPresent(appBindings)) {
|
if (isPresent(appProviders)) {
|
||||||
bindings.push(appBindings);
|
bindings.push(appProviders);
|
||||||
}
|
}
|
||||||
return p.application(bindings).bootstrap(appComponentType);
|
return p.application(bindings).bootstrap(appComponentType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ import {Compiler_} from "./linker/compiler";
|
||||||
* These are providers that should be singletons shared among all Angular applications
|
* These are providers that should be singletons shared among all Angular applications
|
||||||
* running on the page.
|
* running on the page.
|
||||||
*/
|
*/
|
||||||
export function platformBindings(): Array<Type | Provider | any[]> {
|
export function platformProviders(): Array<Type | Provider | any[]> {
|
||||||
return [provide(Reflector, {useValue: reflector}), TestabilityRegistry];
|
return [provide(Reflector, {useValue: reflector}), TestabilityRegistry];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ function _componentProviders(appComponentType: Type): Array<Type | Provider | an
|
||||||
provide(APP_COMPONENT_REF_PROMISE,
|
provide(APP_COMPONENT_REF_PROMISE,
|
||||||
{
|
{
|
||||||
useFactory: (dynamicComponentLoader, injector: Injector) => {
|
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)
|
return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector)
|
||||||
.then((componentRef) => {
|
.then((componentRef) => {
|
||||||
if (isPresent(componentRef.location.nativeElement)) {
|
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
|
* 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.
|
* 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 [
|
return [
|
||||||
provide(Compiler, {useClass: Compiler_}),
|
provide(Compiler, {useClass: Compiler_}),
|
||||||
APP_ID_RANDOM_PROVIDER,
|
APP_ID_RANDOM_PROVIDER,
|
||||||
|
@ -121,10 +121,10 @@ export function createNgZone(): NgZone {
|
||||||
|
|
||||||
var _platform: PlatformRef;
|
var _platform: PlatformRef;
|
||||||
|
|
||||||
export function platformCommon(bindings?: Array<Type | Provider | any[]>, initializer?: () => void):
|
export function platformCommon(providers?: Array<Type | Provider | any[]>,
|
||||||
PlatformRef {
|
initializer?: () => void): PlatformRef {
|
||||||
if (isPresent(_platform)) {
|
if (isPresent(_platform)) {
|
||||||
if (isBlank(bindings)) {
|
if (isBlank(providers)) {
|
||||||
return _platform;
|
return _platform;
|
||||||
}
|
}
|
||||||
throw "platform() can only be called once per page";
|
throw "platform() can only be called once per page";
|
||||||
|
@ -134,10 +134,10 @@ export function platformCommon(bindings?: Array<Type | Provider | any[]>, initia
|
||||||
initializer();
|
initializer();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isBlank(bindings)) {
|
if (isBlank(providers)) {
|
||||||
bindings = platformBindings();
|
providers = platformProviders();
|
||||||
}
|
}
|
||||||
_platform = new PlatformRef_(Injector.resolveAndCreate(bindings), () => { _platform = null; });
|
_platform = new PlatformRef_(Injector.resolveAndCreate(providers), () => { _platform = null; });
|
||||||
return _platform;
|
return _platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ export abstract class PlatformRef {
|
||||||
* renderer, and other framework components. An application hosts one or more
|
* renderer, and other framework components. An application hosts one or more
|
||||||
* root components, which can be initialized via `ApplicationRef.bootstrap()`.
|
* root components, which can be initialized via `ApplicationRef.bootstrap()`.
|
||||||
*
|
*
|
||||||
*##Application Bindings
|
*##Application Providers
|
||||||
*
|
*
|
||||||
* Angular applications require numerous providers to be properly instantiated.
|
* Angular applications require numerous providers to be properly instantiated.
|
||||||
* When using `application()` to create a new app on the page, these providers
|
* When using `application()` to create a new app on the page, these providers
|
||||||
|
@ -179,17 +179,17 @@ export abstract class PlatformRef {
|
||||||
*
|
*
|
||||||
* ### Example
|
* ### Example
|
||||||
* ```
|
* ```
|
||||||
* var myAppBindings = [MyAppService];
|
* var myAppProviders = [MyAppService];
|
||||||
*
|
*
|
||||||
* platform()
|
* platform()
|
||||||
* .application([applicationCommonBindings(), applicationDomBindings(), myAppBindings])
|
* .application([applicationCommonProviders(), applicationDomProviders(), myAppProviders])
|
||||||
* .bootstrap(MyTopLevelComponent);
|
* .bootstrap(MyTopLevelComponent);
|
||||||
* ```
|
* ```
|
||||||
*##See Also
|
*##See Also
|
||||||
*
|
*
|
||||||
* See the {@link bootstrap} documentation for more details.
|
* 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
|
* 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; }
|
get injector(): Injector { return this._injector; }
|
||||||
|
|
||||||
application(bindings: Array<Type | Provider | any[]>): ApplicationRef {
|
application(providers: Array<Type | Provider | any[]>): ApplicationRef {
|
||||||
var app = this._initApp(createNgZone(), bindings);
|
var app = this._initApp(createNgZone(), providers);
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,8 +233,8 @@ export class PlatformRef_ extends PlatformRef {
|
||||||
var zone = createNgZone();
|
var zone = createNgZone();
|
||||||
var completer = PromiseWrapper.completer();
|
var completer = PromiseWrapper.completer();
|
||||||
zone.run(() => {
|
zone.run(() => {
|
||||||
PromiseWrapper.then(bindingFn(zone), (bindings: Array<Type | Provider | any[]>) => {
|
PromiseWrapper.then(bindingFn(zone), (providers: Array<Type | Provider | any[]>) => {
|
||||||
completer.resolve(this._initApp(zone, bindings));
|
completer.resolve(this._initApp(zone, providers));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return completer.promise;
|
return completer.promise;
|
||||||
|
@ -301,20 +301,20 @@ export abstract class ApplicationRef {
|
||||||
* specified application component onto DOM elements identified by the [componentType]'s
|
* specified application component onto DOM elements identified by the [componentType]'s
|
||||||
* selector and kicks off automatic change detection to finish initializing the component.
|
* 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
|
* parameter. These providers will only apply for the root component being added and any
|
||||||
* child components under it.
|
* child components under it.
|
||||||
*
|
*
|
||||||
* ### Example
|
* ### Example
|
||||||
* ```
|
* ```
|
||||||
* var app = platform.application([applicationCommonBindings(), applicationDomBindings()];
|
* var app = platform.application([applicationCommonProviders(), applicationDomProviders()];
|
||||||
* app.bootstrap(FirstRootComponent);
|
* app.bootstrap(FirstRootComponent);
|
||||||
* app.bootstrap(SecondRootComponent, [provide(OverrideBinding, {useClass: OverriddenBinding})]);
|
* 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>;
|
Promise<ComponentRef>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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 =
|
export const APP_ID_RANDOM_PROVIDER: Provider =
|
||||||
CONST_EXPR(new Provider(APP_ID, {useFactory: _appIdRandomProviderFactory, deps: []}));
|
CONST_EXPR(new Provider(APP_ID, {useFactory: _appIdRandomProviderFactory, deps: []}));
|
||||||
|
|
|
@ -29,7 +29,7 @@ import {
|
||||||
platformCommon,
|
platformCommon,
|
||||||
PlatformRef,
|
PlatformRef,
|
||||||
ApplicationRef,
|
ApplicationRef,
|
||||||
applicationCommonBindings
|
applicationCommonProviders
|
||||||
} from 'angular2/src/core/application_ref';
|
} from 'angular2/src/core/application_ref';
|
||||||
import {Serializer} from "angular2/src/web_workers/shared/serializer";
|
import {Serializer} from "angular2/src/web_workers/shared/serializer";
|
||||||
import {ON_WEB_WORKER} from "angular2/src/web_workers/shared/api";
|
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
|
* If no providers are specified, `platform`'s behavior depends on whether an existing
|
||||||
* platform exists:
|
* 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
|
* 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
|
* 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);
|
var emitter = bus.from(SETUP_CHANNEL);
|
||||||
subscription = ObservableWrapper.subscribe(emitter, (message: {[key: string]: any}) => {
|
subscription = ObservableWrapper.subscribe(emitter, (message: {[key: string]: any}) => {
|
||||||
var bindings =
|
var bindings =
|
||||||
[applicationCommonBindings(), webWorkerProviders(appComponentType, bus, message)];
|
[applicationCommonProviders(), webWorkerProviders(appComponentType, bus, message)];
|
||||||
if (isPresent(appProviders)) {
|
if (isPresent(appProviders)) {
|
||||||
bindings.push(appProviders);
|
bindings.push(appProviders);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1142,7 +1142,7 @@ var NG_API = [
|
||||||
'WrappedValue.wrapped=',
|
'WrappedValue.wrapped=',
|
||||||
'WtfScopeFn:dart',
|
'WtfScopeFn:dart',
|
||||||
'ZeroArgFunction:dart',
|
'ZeroArgFunction:dart',
|
||||||
'applicationCommonBindings()',
|
'applicationCommonProviders()',
|
||||||
'asNativeElements()',
|
'asNativeElements()',
|
||||||
'bind()',
|
'bind()',
|
||||||
'provide()',
|
'provide()',
|
||||||
|
@ -1152,7 +1152,7 @@ var NG_API = [
|
||||||
'inspectElement()',
|
'inspectElement()',
|
||||||
'inspectNativeElement()',
|
'inspectNativeElement()',
|
||||||
'platform():js',
|
'platform():js',
|
||||||
'platformBindings()',
|
'platformProviders()',
|
||||||
'platformCommon()',
|
'platformCommon()',
|
||||||
'resolveForwardRef():js',
|
'resolveForwardRef():js',
|
||||||
'wtfCreateScope():js',
|
'wtfCreateScope():js',
|
||||||
|
|
|
@ -15,8 +15,8 @@ import {
|
||||||
Provider,
|
Provider,
|
||||||
Type
|
Type
|
||||||
} from 'angular2/angular2';
|
} from 'angular2/angular2';
|
||||||
import {applicationDomBindings} from 'angular2/src/core/application_common';
|
import {applicationDomProviders} from 'angular2/src/core/application_common';
|
||||||
import {applicationCommonBindings} from 'angular2/src/core/application_ref';
|
import {applicationCommonProviders} from 'angular2/src/core/application_ref';
|
||||||
import {compilerProviders} from 'angular2/src/core/compiler/compiler';
|
import {compilerProviders} from 'angular2/src/core/compiler/compiler';
|
||||||
|
|
||||||
import {getComponentInfo, ComponentInfo} from './metadata';
|
import {getComponentInfo, ComponentInfo} from './metadata';
|
||||||
|
@ -298,8 +298,8 @@ export class UpgradeAdapter {
|
||||||
var ng1Injector: angular.auto.IInjectorService = null;
|
var ng1Injector: angular.auto.IInjectorService = null;
|
||||||
var platformRef: PlatformRef = platform();
|
var platformRef: PlatformRef = platform();
|
||||||
var applicationRef: ApplicationRef = platformRef.application([
|
var applicationRef: ApplicationRef = platformRef.application([
|
||||||
applicationCommonBindings(),
|
applicationCommonProviders(),
|
||||||
applicationDomBindings(),
|
applicationDomProviders(),
|
||||||
compilerProviders(),
|
compilerProviders(),
|
||||||
provide(NG1_INJECTOR, {useFactory: () => ng1Injector}),
|
provide(NG1_INJECTOR, {useFactory: () => ng1Injector}),
|
||||||
provide(NG1_COMPILE, {useFactory: () => ng1Injector.get(NG1_COMPILE)}),
|
provide(NG1_COMPILE, {useFactory: () => ng1Injector.get(NG1_COMPILE)}),
|
||||||
|
|
Loading…
Reference in New Issue