feat(di): change the params of Provider and provide to start with "use"

Closes #4684
This commit is contained in:
vsavkin 2015-10-12 11:30:34 -07:00 committed by Victor Savkin
parent f443ecbfa6
commit 1aeafd31bd
110 changed files with 466 additions and 434 deletions

View File

@ -107,7 +107,7 @@ export {URLSearchParams} from './src/http/url_search_params';
* search: string = 'coreTeam=true'; * search: string = 'coreTeam=true';
* } * }
* *
* bootstrap(App, [HTTP_PROVIDERS, provide(RequestOptions, {asClass: MyOptions})]) * bootstrap(App, [HTTP_PROVIDERS, provide(RequestOptions, {useClass: MyOptions})])
* .catch(err => console.error(err)); * .catch(err => console.error(err));
* ``` * ```
* *
@ -125,7 +125,7 @@ export {URLSearchParams} from './src/http/url_search_params';
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* HTTP_PROVIDERS, * HTTP_PROVIDERS,
* MockBackend, * MockBackend,
* provide(XHRBackend, {asAlias: MockBackend}) * provide(XHRBackend, {useExisting: MockBackend})
* ]); * ]);
* var http = injector.get(Http); * var http = injector.get(Http);
* var backend = injector.get(MockBackend); * var backend = injector.get(MockBackend);
@ -153,12 +153,12 @@ export const HTTP_PROVIDERS: any[] = [
// issue: https://github.com/angular/angular/issues/3183 // issue: https://github.com/angular/angular/issues/3183
provide(Http, provide(Http,
{ {
asFactory: (xhrBackend, requestOptions) => new Http(xhrBackend, requestOptions), useFactory: (xhrBackend, requestOptions) => new Http(xhrBackend, requestOptions),
deps: [XHRBackend, RequestOptions] deps: [XHRBackend, RequestOptions]
}), }),
BrowserXhr, BrowserXhr,
provide(RequestOptions, {asClass: BaseRequestOptions}), provide(RequestOptions, {useClass: BaseRequestOptions}),
provide(ResponseOptions, {asClass: BaseResponseOptions}), provide(ResponseOptions, {useClass: BaseResponseOptions}),
XHRBackend XHRBackend
]; ];
@ -230,7 +230,7 @@ export const HTTP_BINDINGS = HTTP_PROVIDERS;
* search: string = 'coreTeam=true'; * search: string = 'coreTeam=true';
* } * }
* *
* bootstrap(App, [JSONP_PROVIDERS, provide(RequestOptions, {asClass: MyOptions})]) * bootstrap(App, [JSONP_PROVIDERS, provide(RequestOptions, {useClass: MyOptions})])
* .catch(err => console.error(err)); * .catch(err => console.error(err));
* ``` * ```
* *
@ -247,7 +247,7 @@ export const HTTP_BINDINGS = HTTP_PROVIDERS;
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* JSONP_PROVIDERS, * JSONP_PROVIDERS,
* MockBackend, * MockBackend,
* provide(JSONPBackend, {asAlias: MockBackend}) * provide(JSONPBackend, {useExisting: MockBackend})
* ]); * ]);
* var jsonp = injector.get(Jsonp); * var jsonp = injector.get(Jsonp);
* var backend = injector.get(MockBackend); * var backend = injector.get(MockBackend);
@ -275,13 +275,13 @@ export const JSONP_PROVIDERS: any[] = [
// issue: https://github.com/angular/angular/issues/3183 // issue: https://github.com/angular/angular/issues/3183
provide(Jsonp, provide(Jsonp,
{ {
asFactory: (jsonpBackend, requestOptions) => new Jsonp(jsonpBackend, requestOptions), useFactory: (jsonpBackend, requestOptions) => new Jsonp(jsonpBackend, requestOptions),
deps: [JSONPBackend, RequestOptions] deps: [JSONPBackend, RequestOptions]
}), }),
BrowserJsonp, BrowserJsonp,
provide(RequestOptions, {asClass: BaseRequestOptions}), provide(RequestOptions, {useClass: BaseRequestOptions}),
provide(ResponseOptions, {asClass: BaseResponseOptions}), provide(ResponseOptions, {useClass: BaseResponseOptions}),
provide(JSONPBackend, {asClass: JSONPBackend_}) provide(JSONPBackend, {useClass: JSONPBackend_})
]; ];
/** /**

View File

@ -111,17 +111,17 @@ export const ROUTER_DIRECTIVES: any[] = CONST_EXPR([RouterOutlet, RouterLink]);
*/ */
export const ROUTER_PROVIDERS: any[] = CONST_EXPR([ export const ROUTER_PROVIDERS: any[] = CONST_EXPR([
RouteRegistry, RouteRegistry,
CONST_EXPR(new Provider(LocationStrategy, {toClass: PathLocationStrategy})), CONST_EXPR(new Provider(LocationStrategy, {useClass: PathLocationStrategy})),
Location, Location,
CONST_EXPR( CONST_EXPR(
new Provider(Router, new Provider(Router,
{ {
toFactory: routerFactory, useFactory: routerFactory,
deps: CONST_EXPR([RouteRegistry, Location, ROUTER_PRIMARY_COMPONENT]) deps: CONST_EXPR([RouteRegistry, Location, ROUTER_PRIMARY_COMPONENT])
})), })),
CONST_EXPR(new Provider( CONST_EXPR(new Provider(
ROUTER_PRIMARY_COMPONENT, ROUTER_PRIMARY_COMPONENT,
{toFactory: routerPrimaryComponentFactory, deps: CONST_EXPR([ApplicationRef])})) {useFactory: routerPrimaryComponentFactory, deps: CONST_EXPR([ApplicationRef])}))
]); ]);
/** /**

View File

@ -49,17 +49,17 @@ export function applicationDomBindings(): Array<Type | Provider | any[]> {
throw "Must set a root DOM adapter first."; throw "Must set a root DOM adapter first.";
} }
return [ return [
provide(DOCUMENT, {asValue: DOM.defaultDoc()}), provide(DOCUMENT, {useValue: DOM.defaultDoc()}),
EventManager, EventManager,
new Provider(EVENT_MANAGER_PLUGINS, {toClass: DomEventsPlugin, multi: true}), new Provider(EVENT_MANAGER_PLUGINS, {useClass: DomEventsPlugin, multi: true}),
new Provider(EVENT_MANAGER_PLUGINS, {toClass: KeyEventsPlugin, multi: true}), new Provider(EVENT_MANAGER_PLUGINS, {useClass: KeyEventsPlugin, multi: true}),
new Provider(EVENT_MANAGER_PLUGINS, {toClass: HammerGesturesPlugin, multi: true}), new Provider(EVENT_MANAGER_PLUGINS, {useClass: HammerGesturesPlugin, multi: true}),
provide(DomRenderer, {asClass: DomRenderer_}), provide(DomRenderer, {useClass: DomRenderer_}),
provide(Renderer, {asAlias: DomRenderer}), provide(Renderer, {useExisting: DomRenderer}),
DomSharedStylesHost, DomSharedStylesHost,
provide(SharedStylesHost, {asAlias: DomSharedStylesHost}), provide(SharedStylesHost, {useExisting: DomSharedStylesHost}),
EXCEPTION_PROVIDER, EXCEPTION_PROVIDER,
provide(XHR, {asValue: new XHRImpl()}), provide(XHR, {useValue: new XHRImpl()}),
Testability, Testability,
BrowserDetails, BrowserDetails,
AnimationBuilder, AnimationBuilder,

View File

@ -50,7 +50,7 @@ import {Compiler_} from "./linker/compiler";
* running on the page. * running on the page.
*/ */
export function platformBindings(): Array<Type | Provider | any[]> { export function platformBindings(): Array<Type | Provider | any[]> {
return [provide(Reflector, {asValue: reflector}), TestabilityRegistry]; return [provide(Reflector, {useValue: reflector}), TestabilityRegistry];
} }
/** /**
@ -58,10 +58,10 @@ export function platformBindings(): Array<Type | Provider | any[]> {
*/ */
function _componentProviders(appComponentType: Type): Array<Type | Provider | any[]> { function _componentProviders(appComponentType: Type): Array<Type | Provider | any[]> {
return [ return [
provide(APP_COMPONENT, {asValue: appComponentType}), provide(APP_COMPONENT, {useValue: appComponentType}),
provide(APP_COMPONENT_REF_PROMISE, provide(APP_COMPONENT_REF_PROMISE,
{ {
asFactory: (dynamicComponentLoader, injector: Injector) => { useFactory: (dynamicComponentLoader, injector: Injector) => {
// TODO(rado): investigate whether to support bindings on root component. // TODO(rado): investigate whether to support bindings on root component.
return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector) return dynamicComponentLoader.loadAsRoot(appComponentType, null, injector)
.then((componentRef) => { .then((componentRef) => {
@ -77,7 +77,7 @@ function _componentProviders(appComponentType: Type): Array<Type | Provider | an
}), }),
provide(appComponentType, provide(appComponentType,
{ {
asFactory: (p: Promise<any>) => p.then(ref => ref.instance), useFactory: (p: Promise<any>) => p.then(ref => ref.instance),
deps: [APP_COMPONENT_REF_PROMISE] deps: [APP_COMPONENT_REF_PROMISE]
}), }),
]; ];
@ -89,24 +89,24 @@ function _componentProviders(appComponentType: Type): Array<Type | Provider | an
*/ */
export function applicationCommonBindings(): Array<Type | Provider | any[]> { export function applicationCommonBindings(): Array<Type | Provider | any[]> {
return [ return [
provide(Compiler, {asClass: Compiler_}), provide(Compiler, {useClass: Compiler_}),
APP_ID_RANDOM_PROVIDER, APP_ID_RANDOM_PROVIDER,
AppViewPool, AppViewPool,
provide(APP_VIEW_POOL_CAPACITY, {asValue: 10000}), provide(APP_VIEW_POOL_CAPACITY, {useValue: 10000}),
provide(AppViewManager, {asClass: AppViewManager_}), provide(AppViewManager, {useClass: AppViewManager_}),
AppViewManagerUtils, AppViewManagerUtils,
AppViewListener, AppViewListener,
ProtoViewFactory, ProtoViewFactory,
ViewResolver, ViewResolver,
DEFAULT_PIPES, DEFAULT_PIPES,
provide(IterableDiffers, {asValue: defaultIterableDiffers}), provide(IterableDiffers, {useValue: defaultIterableDiffers}),
provide(KeyValueDiffers, {asValue: defaultKeyValueDiffers}), provide(KeyValueDiffers, {useValue: defaultKeyValueDiffers}),
DirectiveResolver, DirectiveResolver,
PipeResolver, PipeResolver,
provide(DynamicComponentLoader, {asClass: DynamicComponentLoader_}), provide(DynamicComponentLoader, {useClass: DynamicComponentLoader_}),
provide(LifeCycle, provide(LifeCycle,
{ {
asFactory: (exceptionHandler) => new LifeCycle_(null, assertionsEnabled()), useFactory: (exceptionHandler) => new LifeCycle_(null, assertionsEnabled()),
deps: [ExceptionHandler] deps: [ExceptionHandler]
}) })
]; ];
@ -236,8 +236,8 @@ export class PlatformRef_ extends PlatformRef {
var injector: Injector; var injector: Injector;
var app: ApplicationRef; var app: ApplicationRef;
zone.run(() => { zone.run(() => {
providers.push(provide(NgZone, {asValue: zone})); providers.push(provide(NgZone, {useValue: zone}));
providers.push(provide(ApplicationRef, {asFactory: (): ApplicationRef => app, deps: []})); providers.push(provide(ApplicationRef, {useFactory: (): ApplicationRef => app, deps: []}));
var exceptionHandler; var exceptionHandler;
try { try {
@ -297,7 +297,7 @@ export abstract class ApplicationRef {
* ``` * ```
* var app = platform.application([applicationCommonBindings(), applicationDomBindings()]; * var app = platform.application([applicationCommonBindings(), applicationDomBindings()];
* app.bootstrap(FirstRootComponent); * app.bootstrap(FirstRootComponent);
* app.bootstrap(SecondRootComponent, [provide(OverrideBinding, {asClass: OverriddenBinding})]); * app.bootstrap(SecondRootComponent, [provide(OverrideBinding, {useClass: OverriddenBinding})]);
* ``` * ```
*/ */
abstract bootstrap(componentType: Type, bindings?: Array<Type | Provider | any[]>): abstract bootstrap(componentType: Type, bindings?: Array<Type | Provider | any[]>):

View File

@ -43,7 +43,7 @@ function _appIdRandomProviderFactory() {
* Bindings that will generate a random APP_ID_TOKEN. * Bindings 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, {toFactory: _appIdRandomProviderFactory, deps: []})); CONST_EXPR(new Provider(APP_ID, {useFactory: _appIdRandomProviderFactory, deps: []}));
function _randomChar(): string { function _randomChar(): string {
return StringWrapper.fromCharCode(97 + Math.floor(Math.random() * 25)); return StringWrapper.fromCharCode(97 + Math.floor(Math.random() * 25));

View File

@ -56,7 +56,7 @@ export class IterableDiffers {
*/ */
static extend(factories: IterableDifferFactory[]): Provider { static extend(factories: IterableDifferFactory[]): Provider {
return new Provider(IterableDiffers, { return new Provider(IterableDiffers, {
toFactory: (parent: IterableDiffers) => { useFactory: (parent: IterableDiffers) => {
if (isBlank(parent)) { if (isBlank(parent)) {
// Typically would occur when calling IterableDiffers.extend inside of dependencies passed // Typically would occur when calling IterableDiffers.extend inside of dependencies passed
// to // to

View File

@ -56,7 +56,7 @@ export class KeyValueDiffers {
*/ */
static extend(factories: KeyValueDifferFactory[]): Provider { static extend(factories: KeyValueDifferFactory[]): Provider {
return new Provider(KeyValueDiffers, { return new Provider(KeyValueDiffers, {
toFactory: (parent: KeyValueDiffers) => { useFactory: (parent: KeyValueDiffers) => {
if (isBlank(parent)) { if (isBlank(parent)) {
// Typically would occur when calling KeyValueDiffers.extend inside of dependencies passed // Typically would occur when calling KeyValueDiffers.extend inside of dependencies passed
// to // to

View File

@ -42,16 +42,16 @@ export function compilerProviders(): Array<Type | Provider | any[]> {
ChangeDetectionCompiler, ChangeDetectionCompiler,
provide(ChangeDetectorGenConfig, provide(ChangeDetectorGenConfig,
{ {
asValue: useValue:
new ChangeDetectorGenConfig(assertionsEnabled(), assertionsEnabled(), false, true) new ChangeDetectorGenConfig(assertionsEnabled(), assertionsEnabled(), false, true)
}), }),
TemplateCompiler, TemplateCompiler,
provide(RuntimeCompiler, {asClass: RuntimeCompiler_}), provide(RuntimeCompiler, {useClass: RuntimeCompiler_}),
provide(Compiler, {asAlias: RuntimeCompiler}), provide(Compiler, {useExisting: RuntimeCompiler}),
DomElementSchemaRegistry, DomElementSchemaRegistry,
provide(ElementSchemaRegistry, {asAlias: DomElementSchemaRegistry}), provide(ElementSchemaRegistry, {useExisting: DomElementSchemaRegistry}),
AnchorBasedAppRootUrl, AnchorBasedAppRootUrl,
provide(AppRootUrl, {asAlias: AnchorBasedAppRootUrl}), provide(AppRootUrl, {useExisting: AnchorBasedAppRootUrl}),
UrlResolver UrlResolver
]; ];
} }

View File

@ -69,7 +69,7 @@ export class DebugElementViewListener implements AppViewListener {
export const ELEMENT_PROBE_PROVIDERS: any[] = CONST_EXPR([ export const ELEMENT_PROBE_PROVIDERS: any[] = CONST_EXPR([
DebugElementViewListener, DebugElementViewListener,
CONST_EXPR(new Provider(AppViewListener, {toAlias: DebugElementViewListener})), CONST_EXPR(new Provider(AppViewListener, {useExisting: DebugElementViewListener})),
]); ]);
export const ELEMENT_PROBE_BINDINGS = ELEMENT_PROBE_PROVIDERS; export const ELEMENT_PROBE_BINDINGS = ELEMENT_PROBE_PROVIDERS;

View File

@ -91,8 +91,8 @@ export class NoProviderError extends AbstractProviderError {
* *
* ```typescript * ```typescript
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* provide("one", {asFactory: (two) => "two", deps: [[new Inject("two")]]}), * provide("one", {useFactory: (two) => "two", deps: [[new Inject("two")]]}),
* provide("two", {asFactory: (one) => "one", deps: [[new Inject("one")]]}) * provide("two", {useFactory: (one) => "one", deps: [[new Inject("one")]]})
* ]); * ]);
* *
* expect(() => injector.get("one")).toThrowError(); * expect(() => injector.get("one")).toThrowError();
@ -252,8 +252,8 @@ export class OutOfBoundsError extends BaseException {
* *
* ```typescript * ```typescript
* expect(() => Injector.resolveAndCreate([ * expect(() => Injector.resolveAndCreate([
* new Provider("Strings", {toValue: "string1", multi: true}), * new Provider("Strings", {useValue: "string1", multi: true}),
* new Provider("Strings", {toValue: "string2", multi: false}) * new Provider("Strings", {useValue: "string2", multi: false})
* ])).toThrowError(); * ])).toThrowError();
* ``` * ```
*/ */

View File

@ -563,7 +563,7 @@ export class Injector {
* *
* ```typescript * ```typescript
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* provide("validToken", {asValue: "Value"}) * provide("validToken", {useValue: "Value"})
* ]); * ]);
* expect(injector.get("validToken")).toEqual("Value"); * expect(injector.get("validToken")).toEqual("Value");
* expect(() => injector.get("invalidToken")).toThrowError(); * expect(() => injector.get("invalidToken")).toThrowError();
@ -588,7 +588,7 @@ export class Injector {
* *
* ```typescript * ```typescript
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* provide("validToken", {asValue: "Value"}) * provide("validToken", {useValue: "Value"})
* ]); * ]);
* expect(injector.getOptional("validToken")).toEqual("Value"); * expect(injector.getOptional("validToken")).toEqual("Value");
* expect(injector.getOptional("invalidToken")).toBe(null); * expect(injector.getOptional("invalidToken")).toBe(null);

View File

@ -17,7 +17,7 @@ import {CONST, CONST_EXPR, stringify, isBlank, isPresent} from "angular2/src/cor
* } * }
* *
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* provide("MyEngine", {asClass: Engine}), * provide("MyEngine", {useClass: Engine}),
* Car * Car
* ]); * ]);
* *

View File

@ -9,7 +9,7 @@ import {CONST} from 'angular2/src/core/facade/lang';
* var t = new OpaqueToken("value"); * var t = new OpaqueToken("value");
* *
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* provide(t, {asValue: "providedValue"}) * provide(t, {useValue: "providedValue"})
* ]); * ]);
* *
* expect(injector.get(t)).toEqual("bindingValue"); * expect(injector.get(t)).toEqual("bindingValue");

View File

@ -48,7 +48,7 @@ const _EMPTY_LIST = CONST_EXPR([]);
* *
* ```javascript * ```javascript
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* new Provider("message", { toValue: 'Hello' }) * new Provider("message", { useValue: 'Hello' })
* ]); * ]);
* *
* expect(injector.get("message")).toEqual('Hello'); * expect(injector.get("message")).toEqual('Hello');
@ -66,7 +66,8 @@ export class Provider {
* *
* ### Example ([live demo](http://plnkr.co/edit/RSTG86qgmoxCyj9SWPwY?p=preview)) * ### Example ([live demo](http://plnkr.co/edit/RSTG86qgmoxCyj9SWPwY?p=preview))
* *
* Because `toAlias` and `toClass` are often confused, the example contains both use cases for * Because `useExisting` and `useClass` are often confused, the example contains both use cases
* for
* easy * easy
* comparison. * comparison.
* *
@ -77,11 +78,11 @@ export class Provider {
* *
* var injectorClass = Injector.resolveAndCreate([ * var injectorClass = Injector.resolveAndCreate([
* Car, * Car,
* new Provider(Vehicle, { toClass: Car }) * new Provider(Vehicle, { useClass: Car })
* ]); * ]);
* var injectorAlias = Injector.resolveAndCreate([ * var injectorAlias = Injector.resolveAndCreate([
* Car, * Car,
* new Provider(Vehicle, { toAlias: Car }) * new Provider(Vehicle, { useExisting: Car })
* ]); * ]);
* *
* expect(injectorClass.get(Vehicle)).not.toBe(injectorClass.get(Car)); * expect(injectorClass.get(Vehicle)).not.toBe(injectorClass.get(Car));
@ -91,7 +92,7 @@ export class Provider {
* expect(injectorAlias.get(Vehicle) instanceof Car).toBe(true); * expect(injectorAlias.get(Vehicle) instanceof Car).toBe(true);
* ``` * ```
*/ */
toClass: Type; useClass: Type;
/** /**
* Binds a DI token to a value. * Binds a DI token to a value.
@ -100,23 +101,24 @@ export class Provider {
* *
* ```javascript * ```javascript
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* new Provider("message", { toValue: 'Hello' }) * new Provider("message", { useValue: 'Hello' })
* ]); * ]);
* *
* expect(injector.get("message")).toEqual('Hello'); * expect(injector.get("message")).toEqual('Hello');
* ``` * ```
*/ */
toValue; useValue;
/** /**
* Binds a DI token as an alias for an existing token. * Binds a DI token to an existing token.
* *
* An alias means that {@link Injector} returns the same instance as if the alias token was used. * {@link Injector} returns the same instance as if the provided token was used.
* This is in contrast to `toClass` where a separate instance of `toClass` is returned. * This is in contrast to `useClass` where a separate instance of `useClass` is returned.
* *
* ### Example ([live demo](http://plnkr.co/edit/QsatsOJJ6P8T2fMe9gr8?p=preview)) * ### Example ([live demo](http://plnkr.co/edit/QsatsOJJ6P8T2fMe9gr8?p=preview))
* *
* Because `toAlias` and `toClass` are often confused the example contains both use cases for easy * Because `useExisting` and `useClass` are often confused the example contains both use cases for
* easy
* comparison. * comparison.
* *
* ```typescript * ```typescript
@ -126,11 +128,11 @@ export class Provider {
* *
* var injectorAlias = Injector.resolveAndCreate([ * var injectorAlias = Injector.resolveAndCreate([
* Car, * Car,
* new Provider(Vehicle, { toAlias: Car }) * new Provider(Vehicle, { useExisting: Car })
* ]); * ]);
* var injectorClass = Injector.resolveAndCreate([ * var injectorClass = Injector.resolveAndCreate([
* Car, * Car,
* new Provider(Vehicle, { toClass: Car }) * new Provider(Vehicle, { useClass: Car })
* ]); * ]);
* *
* expect(injectorAlias.get(Vehicle)).toBe(injectorAlias.get(Car)); * expect(injectorAlias.get(Vehicle)).toBe(injectorAlias.get(Car));
@ -140,7 +142,7 @@ export class Provider {
* expect(injectorClass.get(Vehicle) instanceof Car).toBe(true); * expect(injectorClass.get(Vehicle) instanceof Car).toBe(true);
* ``` * ```
*/ */
toAlias; useExisting;
/** /**
* Binds a DI token to a function which computes the value. * Binds a DI token to a function which computes the value.
@ -149,8 +151,8 @@ export class Provider {
* *
* ```typescript * ```typescript
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* new Provider(Number, { toFactory: () => { return 1+2; }}), * new Provider(Number, { useFactory: () => { return 1+2; }}),
* new Provider(String, { toFactory: (value) => { return "Value: " + value; }, * new Provider(String, { useFactory: (value) => { return "Value: " + value; },
* deps: [Number] }) * deps: [Number] })
* ]); * ]);
* *
@ -160,7 +162,7 @@ export class Provider {
* *
* Used in conjuction with dependencies. * Used in conjuction with dependencies.
*/ */
toFactory: Function; useFactory: Function;
/** /**
* Specifies a set of dependencies * Specifies a set of dependencies
@ -170,8 +172,8 @@ export class Provider {
* *
* ```typescript * ```typescript
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* new Provider(Number, { toFactory: () => { return 1+2; }}), * new Provider(Number, { useFactory: () => { return 1+2; }}),
* new Provider(String, { toFactory: (value) => { return "Value: " + value; }, * new Provider(String, { useFactory: (value) => { return "Value: " + value; },
* deps: [Number] }) * deps: [Number] })
* ]); * ]);
* *
@ -179,26 +181,26 @@ export class Provider {
* expect(injector.get(String)).toEqual('Value: 3'); * expect(injector.get(String)).toEqual('Value: 3');
* ``` * ```
* *
* Used in conjunction with `toFactory`. * Used in conjunction with `useFactory`.
*/ */
dependencies: Object[]; dependencies: Object[];
/** @internal */ /** @internal */
_multi: boolean; _multi: boolean;
constructor(token, {toClass, toValue, toAlias, toFactory, deps, multi}: { constructor(token, {useClass, useValue, useExisting, useFactory, deps, multi}: {
toClass?: Type, useClass?: Type,
toValue?: any, useValue?: any,
toAlias?: any, useExisting?: any,
toFactory?: Function, useFactory?: Function,
deps?: Object[], deps?: Object[],
multi?: boolean multi?: boolean
}) { }) {
this.token = token; this.token = token;
this.toClass = toClass; this.useClass = useClass;
this.toValue = toValue; this.useValue = useValue;
this.toAlias = toAlias; this.useExisting = useExisting;
this.toFactory = toFactory; this.useFactory = useFactory;
this.dependencies = deps; this.dependencies = deps;
this._multi = multi; this._multi = multi;
} }
@ -216,8 +218,8 @@ export class Provider {
* *
* ```typescript * ```typescript
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* new Provider("Strings", { toValue: "String1", multi: true}), * new Provider("Strings", { useValue: "String1", multi: true}),
* new Provider("Strings", { toValue: "String2", multi: true}) * new Provider("Strings", { useValue: "String2", multi: true})
* ]); * ]);
* *
* expect(injector.get("Strings")).toEqual(["String1", "String2"]); * expect(injector.get("Strings")).toEqual(["String1", "String2"]);
@ -228,8 +230,8 @@ export class Provider {
* *
* ```typescript * ```typescript
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* new Provider("Strings", { toValue: "String1", multi: true }), * new Provider("Strings", { useValue: "String1", multi: true }),
* new Provider("Strings", { toValue: "String2"}) * new Provider("Strings", { useValue: "String2"})
* ]); * ]);
* ``` * ```
*/ */
@ -245,19 +247,37 @@ export class Binding extends Provider {
toClass?: Type, toClass?: Type,
toValue?: any, toValue?: any,
toAlias?: any, toAlias?: any,
toFactory?: Function, toFactory: Function, deps?: Object[], multi?: boolean
deps?: Object[],
multi?: boolean
}) { }) {
super(token, { super(token, {
toClass: toClass, useClass: toClass,
toValue: toValue, useValue: toValue,
toAlias: toAlias, useExisting: toAlias,
toFactory: toFactory, useFactory: toFactory,
deps: deps, deps: deps,
multi: multi multi: multi
}); });
} }
/**
* @deprecated
*/
get toClass() { return this.useClass; }
/**
* @deprecated
*/
get toAlias() { return this.useExisting; }
/**
* @deprecated
*/
get toFactory() { return this.useFactory; }
/**
* @deprecated
*/
get toValue() { return this.useValue; }
} }
/** /**
@ -270,7 +290,7 @@ export class Binding extends Provider {
* ### Example ([live demo](http://plnkr.co/edit/RfEnhh8kUEI0G3qsnIeT?p%3Dpreview&p=preview)) * ### Example ([live demo](http://plnkr.co/edit/RfEnhh8kUEI0G3qsnIeT?p%3Dpreview&p=preview))
* *
* ```typescript * ```typescript
* var resolvedProviders = Injector.resolve([new Provider('message', {toValue: 'Hello'})]); * var resolvedProviders = Injector.resolve([new Provider('message', {useValue: 'Hello'})]);
* var injector = Injector.fromResolvedProviders(resolvedProviders); * var injector = Injector.fromResolvedProviders(resolvedProviders);
* *
* expect(injector.get('message')).toEqual('Hello'); * expect(injector.get('message')).toEqual('Hello');
@ -327,7 +347,7 @@ export class ResolvedFactory {
* *
* To construct a {@link Provider}, bind a `token` to either a class, a value, a factory function, * To construct a {@link Provider}, bind a `token` to either a class, a value, a factory function,
* or * or
* to an alias to another `token`. * to an existing `token`.
* See {@link ProviderBuilder} for more details. * See {@link ProviderBuilder} for more details.
* *
* The `token` is most commonly a class or {@link angular2/di/OpaqueToken}. * The `token` is most commonly a class or {@link angular2/di/OpaqueToken}.
@ -343,19 +363,19 @@ export function bind(token): ProviderBuilder {
* *
* <!-- TODO: improve the docs --> * <!-- TODO: improve the docs -->
*/ */
export function provide(token, {asClass, asValue, asAlias, asFactory, deps, multi}: { export function provide(token, {useClass, useValue, useExisting, useFactory, deps, multi}: {
asClass?: Type, useClass?: Type,
asValue?: any, useValue?: any,
asAlias?: any, useExisting?: any,
asFactory?: Function, useFactory?: Function,
deps?: Object[], deps?: Object[],
multi?: boolean multi?: boolean
}): Provider { }): Provider {
return new Provider(token, { return new Provider(token, {
toClass: asClass, useClass: useClass,
toValue: asValue, useValue: useValue,
toAlias: asAlias, useExisting: useExisting,
toFactory: asFactory, useFactory: useFactory,
deps: deps, deps: deps,
multi: multi multi: multi
}); });
@ -382,11 +402,11 @@ export class ProviderBuilder {
* *
* var injectorClass = Injector.resolveAndCreate([ * var injectorClass = Injector.resolveAndCreate([
* Car, * Car,
* provide(Vehicle, {asClass: Car}) * provide(Vehicle, {useClass: Car})
* ]); * ]);
* var injectorAlias = Injector.resolveAndCreate([ * var injectorAlias = Injector.resolveAndCreate([
* Car, * Car,
* provide(Vehicle, {asAlias: Car}) * provide(Vehicle, {useExisting: Car})
* ]); * ]);
* *
* expect(injectorClass.get(Vehicle)).not.toBe(injectorClass.get(Car)); * expect(injectorClass.get(Vehicle)).not.toBe(injectorClass.get(Car));
@ -401,7 +421,7 @@ export class ProviderBuilder {
throw new BaseException( throw new BaseException(
`Trying to create a class provider but "${stringify(type)}" is not a class!`); `Trying to create a class provider but "${stringify(type)}" is not a class!`);
} }
return new Provider(this.token, {toClass: type}); return new Provider(this.token, {useClass: type});
} }
/** /**
@ -411,19 +431,19 @@ export class ProviderBuilder {
* *
* ```typescript * ```typescript
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* provide('message', {asValue: 'Hello'}) * provide('message', {useValue: 'Hello'})
* ]); * ]);
* *
* expect(injector.get('message')).toEqual('Hello'); * expect(injector.get('message')).toEqual('Hello');
* ``` * ```
*/ */
toValue(value: any): Provider { return new Provider(this.token, {toValue: value}); } toValue(value: any): Provider { return new Provider(this.token, {useValue: value}); }
/** /**
* Binds a DI token as an alias for an existing token. * Binds a DI token to an existing token.
* *
* An alias means that we will return the same instance as if the alias token was used. (This is * Angular will return the same instance as if the provided token was used. (This is
* in contrast to `toClass` where a separate instance of `toClass` will be returned.) * in contrast to `useClass` where a separate instance of `useClass` will be returned.)
* *
* ### Example ([live demo](http://plnkr.co/edit/uBaoF2pN5cfc5AfZapNw?p=preview)) * ### Example ([live demo](http://plnkr.co/edit/uBaoF2pN5cfc5AfZapNw?p=preview))
* *
@ -438,11 +458,11 @@ export class ProviderBuilder {
* *
* var injectorAlias = Injector.resolveAndCreate([ * var injectorAlias = Injector.resolveAndCreate([
* Car, * Car,
* provide(Vehicle, {asAlias: Car}) * provide(Vehicle, {useExisting: Car})
* ]); * ]);
* var injectorClass = Injector.resolveAndCreate([ * var injectorClass = Injector.resolveAndCreate([
* Car, * Car,
* provide(Vehicle, {asClass: Car}) * provide(Vehicle, {useClass: Car})
* ]); * ]);
* *
* expect(injectorAlias.get(Vehicle)).toBe(injectorAlias.get(Car)); * expect(injectorAlias.get(Vehicle)).toBe(injectorAlias.get(Car));
@ -456,7 +476,7 @@ export class ProviderBuilder {
if (isBlank(aliasToken)) { if (isBlank(aliasToken)) {
throw new BaseException(`Can not alias ${stringify(this.token)} to a blank value!`); throw new BaseException(`Can not alias ${stringify(this.token)} to a blank value!`);
} }
return new Provider(this.token, {toAlias: aliasToken}); return new Provider(this.token, {useExisting: aliasToken});
} }
/** /**
@ -466,8 +486,8 @@ export class ProviderBuilder {
* *
* ```typescript * ```typescript
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* provide(Number, {asFactory: () => { return 1+2; }}), * provide(Number, {useFactory: () => { return 1+2; }}),
* provide(String, {asFactory: (v) => { return "Value: " + v; }, deps: [Number]}) * provide(String, {useFactory: (v) => { return "Value: " + v; }, deps: [Number]})
* ]); * ]);
* *
* expect(injector.get(Number)).toEqual(3); * expect(injector.get(Number)).toEqual(3);
@ -479,7 +499,7 @@ export class ProviderBuilder {
throw new BaseException( throw new BaseException(
`Trying to create a factory provider but "${stringify(factory)}" is not a function!`); `Trying to create a factory provider but "${stringify(factory)}" is not a function!`);
} }
return new Provider(this.token, {toFactory: factory, deps: dependencies}); return new Provider(this.token, {useFactory: factory, deps: dependencies});
} }
} }
@ -489,18 +509,18 @@ export class ProviderBuilder {
export function resolveFactory(provider: Provider): ResolvedFactory { export function resolveFactory(provider: Provider): ResolvedFactory {
var factoryFn: Function; var factoryFn: Function;
var resolvedDeps; var resolvedDeps;
if (isPresent(provider.toClass)) { if (isPresent(provider.useClass)) {
var toClass = resolveForwardRef(provider.toClass); var useClass = resolveForwardRef(provider.useClass);
factoryFn = reflector.factory(toClass); factoryFn = reflector.factory(useClass);
resolvedDeps = _dependenciesFor(toClass); resolvedDeps = _dependenciesFor(useClass);
} else if (isPresent(provider.toAlias)) { } else if (isPresent(provider.useExisting)) {
factoryFn = (aliasInstance) => aliasInstance; factoryFn = (aliasInstance) => aliasInstance;
resolvedDeps = [Dependency.fromKey(Key.get(provider.toAlias))]; resolvedDeps = [Dependency.fromKey(Key.get(provider.useExisting))];
} else if (isPresent(provider.toFactory)) { } else if (isPresent(provider.useFactory)) {
factoryFn = provider.toFactory; factoryFn = provider.useFactory;
resolvedDeps = _constructDependencies(provider.toFactory, provider.dependencies); resolvedDeps = _constructDependencies(provider.useFactory, provider.dependencies);
} else { } else {
factoryFn = () => provider.toValue; factoryFn = () => provider.useValue;
resolvedDeps = _EMPTY_LIST; resolvedDeps = _EMPTY_LIST;
} }
return new ResolvedFactory(factoryFn, resolvedDeps); return new ResolvedFactory(factoryFn, resolvedDeps);
@ -553,7 +573,7 @@ function _normalizeProviders(providers: Array<Type | Provider | ProviderBuilder
Map<number, _NormalizedProvider | _NormalizedProvider[]> { Map<number, _NormalizedProvider | _NormalizedProvider[]> {
providers.forEach(b => { providers.forEach(b => {
if (b instanceof Type) { if (b instanceof Type) {
_normalizeProvider(provide(b, {asClass: b}), res); _normalizeProvider(provide(b, {useClass: b}), res);
} else if (b instanceof Provider) { } else if (b instanceof Provider) {
_normalizeProvider(b, res); _normalizeProvider(b, res);

View File

@ -27,7 +27,7 @@ class _ArrayLogger {
* } * }
* } * }
* *
* bootstrap(MyApp, [provide(ExceptionHandler, {asClass: MyExceptionHandler})]) * bootstrap(MyApp, [provide(ExceptionHandler, {useClass: MyExceptionHandler})])
* *
* ``` * ```
*/ */

View File

@ -8,7 +8,7 @@ import {CONST_EXPR} from 'angular2/src/core/facade/lang';
import {setProperty} from './shared'; import {setProperty} from './shared';
const CHECKBOX_VALUE_ACCESSOR = CONST_EXPR(new Provider( const CHECKBOX_VALUE_ACCESSOR = CONST_EXPR(new Provider(
NG_VALUE_ACCESSOR, {toAlias: forwardRef(() => CheckboxControlValueAccessor), multi: true})); NG_VALUE_ACCESSOR, {useExisting: forwardRef(() => CheckboxControlValueAccessor), multi: true}));
/** /**
* The accessor for writing a value and listening to changes on a checkbox input element. * The accessor for writing a value and listening to changes on a checkbox input element.

View File

@ -7,7 +7,7 @@ import {isBlank, CONST_EXPR} from 'angular2/src/core/facade/lang';
import {setProperty} from './shared'; import {setProperty} from './shared';
const DEFAULT_VALUE_ACCESSOR = CONST_EXPR(new Provider( const DEFAULT_VALUE_ACCESSOR = CONST_EXPR(new Provider(
NG_VALUE_ACCESSOR, {toAlias: forwardRef(() => DefaultValueAccessor), multi: true})); NG_VALUE_ACCESSOR, {useExisting: forwardRef(() => DefaultValueAccessor), multi: true}));
/** /**
* The default accessor for writing a value and listening to changes that is used by the * The default accessor for writing a value and listening to changes that is used by the

View File

@ -10,7 +10,7 @@ import {ControlGroup} from '../model';
import {Form} from './form_interface'; import {Form} from './form_interface';
const controlGroupBinding = const controlGroupBinding =
CONST_EXPR(new Provider(ControlContainer, {toAlias: forwardRef(() => NgControlGroup)})); CONST_EXPR(new Provider(ControlContainer, {useExisting: forwardRef(() => NgControlGroup)}));
/** /**
* Creates and binds a control group to a DOM element. * Creates and binds a control group to a DOM element.

View File

@ -14,7 +14,7 @@ import {Validators, NG_VALIDATORS} from '../validators';
const controlNameBinding = const controlNameBinding =
CONST_EXPR(new Provider(NgControl, {toAlias: forwardRef(() => NgControlName)})); CONST_EXPR(new Provider(NgControl, {useExisting: forwardRef(() => NgControlName)}));
/** /**
* Creates and binds a control with a specified name to a DOM element. * Creates and binds a control with a specified name to a DOM element.

View File

@ -16,7 +16,7 @@ import {AbstractControl, ControlGroup, Control} from '../model';
import {setUpControl} from './shared'; import {setUpControl} from './shared';
const formDirectiveProvider = const formDirectiveProvider =
CONST_EXPR(new Provider(ControlContainer, {toAlias: forwardRef(() => NgForm)})); CONST_EXPR(new Provider(ControlContainer, {useExisting: forwardRef(() => NgForm)}));
/** /**
* If `NgForm` is bound in a component, `<form>` elements in that component will be * If `NgForm` is bound in a component, `<form>` elements in that component will be

View File

@ -11,7 +11,7 @@ import {ControlValueAccessor, NG_VALUE_ACCESSOR} from './control_value_accessor'
import {setUpControl, isPropertyUpdated, selectValueAccessor} from './shared'; import {setUpControl, isPropertyUpdated, selectValueAccessor} from './shared';
const formControlBinding = const formControlBinding =
CONST_EXPR(new Provider(NgControl, {toAlias: forwardRef(() => NgFormControl)})); CONST_EXPR(new Provider(NgControl, {useExisting: forwardRef(() => NgFormControl)}));
/** /**
* Binds an existing {@link Control} to a DOM element. * Binds an existing {@link Control} to a DOM element.

View File

@ -13,7 +13,7 @@ import {Control, ControlGroup} from '../model';
import {setUpControl} from './shared'; import {setUpControl} from './shared';
const formDirectiveProvider = const formDirectiveProvider =
CONST_EXPR(new Provider(ControlContainer, {toAlias: forwardRef(() => NgFormModel)})); CONST_EXPR(new Provider(ControlContainer, {useExisting: forwardRef(() => NgFormModel)}));
/** /**
* Binds an existing control group to a DOM element. * Binds an existing control group to a DOM element.

View File

@ -11,7 +11,7 @@ import {Validators, NG_VALIDATORS} from '../validators';
import {setUpControl, isPropertyUpdated, selectValueAccessor} from './shared'; import {setUpControl, isPropertyUpdated, selectValueAccessor} from './shared';
const formControlBinding = const formControlBinding =
CONST_EXPR(new Provider(NgControl, {toAlias: forwardRef(() => NgModel)})); CONST_EXPR(new Provider(NgControl, {useExisting: forwardRef(() => NgModel)}));
/** /**
* Binds a domain model to a form control. * Binds a domain model to a form control.

View File

@ -9,7 +9,7 @@ import {CONST_EXPR} from 'angular2/src/core/facade/lang';
import {setProperty} from './shared'; import {setProperty} from './shared';
const SELECT_VALUE_ACCESSOR = CONST_EXPR(new Provider( const SELECT_VALUE_ACCESSOR = CONST_EXPR(new Provider(
NG_VALUE_ACCESSOR, {toAlias: forwardRef(() => SelectControlValueAccessor), multi: true})); NG_VALUE_ACCESSOR, {useExisting: forwardRef(() => SelectControlValueAccessor), multi: true}));
/** /**
* Marks `<option>` as dynamic, so Angular can be notified when options change. * Marks `<option>` as dynamic, so Angular can be notified when options change.

View File

@ -4,7 +4,7 @@ import {Directive} from 'angular2/src/core/metadata';
import {Validators, NG_VALIDATORS} from '../validators'; import {Validators, NG_VALIDATORS} from '../validators';
const DEFAULT_VALIDATORS = const DEFAULT_VALIDATORS =
CONST_EXPR(new Provider(NG_VALIDATORS, {toValue: Validators.required, multi: true})); CONST_EXPR(new Provider(NG_VALIDATORS, {useValue: Validators.required, multi: true}));
@Directive({ @Directive({
selector: '[required][ng-control],[required][ng-form-control],[required][ng-model]', selector: '[required][ng-control],[required][ng-form-control],[required][ng-model]',

View File

@ -174,7 +174,7 @@ export class DirectiveProvider extends ResolvedProvider_ {
} }
static createFromType(type: Type, annotation: DirectiveMetadata): DirectiveProvider { static createFromType(type: Type, annotation: DirectiveMetadata): DirectiveProvider {
var provider = new Provider(type, {toClass: type}); var provider = new Provider(type, {useClass: type});
return DirectiveProvider.createFromProvider(provider, annotation); return DirectiveProvider.createFromProvider(provider, annotation);
} }
} }

View File

@ -24,4 +24,4 @@ const DEFAULT_PIPES_LIST = CONST_EXPR([
export const DEFAULT_PIPES_TOKEN: OpaqueToken = CONST_EXPR(new OpaqueToken("Default Pipes")); export const DEFAULT_PIPES_TOKEN: OpaqueToken = CONST_EXPR(new OpaqueToken("Default Pipes"));
export const DEFAULT_PIPES: Provider = export const DEFAULT_PIPES: Provider =
CONST_EXPR(new Provider(DEFAULT_PIPES_TOKEN, {toValue: DEFAULT_PIPES_LIST})); CONST_EXPR(new Provider(DEFAULT_PIPES_TOKEN, {useValue: DEFAULT_PIPES_LIST}));

View File

@ -10,7 +10,7 @@ export class PipeProvider extends ResolvedProvider_ {
} }
static createFromType(type: Type, metadata: PipeMetadata): PipeProvider { static createFromType(type: Type, metadata: PipeMetadata): PipeProvider {
var provider = new Provider(type, {toClass: type}); var provider = new Provider(type, {useClass: type});
var rb = resolveProvider(provider); var rb = resolveProvider(provider);
return new PipeProvider(metadata.name, metadata.pure, rb.key, rb.resolvedFactories, return new PipeProvider(metadata.name, metadata.pure, rb.key, rb.resolvedFactories,
rb.multiProvider); rb.multiProvider);

View File

@ -3,6 +3,6 @@ import {ExceptionHandler} from 'angular2/src/core/facade/exceptions';
import {DOM} from 'angular2/src/core/dom/dom_adapter'; import {DOM} from 'angular2/src/core/dom/dom_adapter';
export const EXCEPTION_PROVIDER = export const EXCEPTION_PROVIDER =
provide(ExceptionHandler, {asFactory: () => new ExceptionHandler(DOM, false), deps: []}); provide(ExceptionHandler, {useFactory: () => new ExceptionHandler(DOM, false), deps: []});
export const EXCEPTION_BINDING = EXCEPTION_PROVIDER; export const EXCEPTION_BINDING = EXCEPTION_PROVIDER;

View File

@ -102,7 +102,7 @@ export class MockConnection implements Connection {
* var connection; * var connection;
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* MockBackend, * MockBackend,
* provide(Http, {asFactory: (backend, defaultOptions) => { * provide(Http, {useFactory: (backend, defaultOptions) => {
* return new Http(backend, defaultOptions) * return new Http(backend, defaultOptions)
* }, deps: [MockBackend, DefaultOptions]})]); * }, deps: [MockBackend, DefaultOptions]})]);
* var http = injector.get(Http); * var http = injector.get(Http);
@ -137,7 +137,7 @@ export class MockBackend implements ConnectionBackend {
* var text; //this will be set from mock response * var text; //this will be set from mock response
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* MockBackend, * MockBackend,
* provide(Http, {asFactory: (backend, options) { * provide(Http, {useFactory: (backend, options) {
* return new Http(backend, options); * return new Http(backend, options);
* }, deps: [MockBackend, BaseRequestOptions]}]); * }, deps: [MockBackend, BaseRequestOptions]}]);
* var backend = injector.get(MockBackend); * var backend = injector.get(MockBackend);

View File

@ -95,7 +95,7 @@ export class XHRConnection implements Connection {
* @Component({ * @Component({
* viewProviders: [ * viewProviders: [
* HTTP_PROVIDERS, * HTTP_PROVIDERS,
* provide(Http, {asFactory: (backend, options) => { * provide(Http, {useFactory: (backend, options) => {
* return new Http(backend, options); * return new Http(backend, options);
* }, deps: [MyNodeBackend, BaseRequestOptions]})] * }, deps: [MyNodeBackend, BaseRequestOptions]})]
* }) * })

View File

@ -125,7 +125,7 @@ export class RequestOptions {
* search: string = 'coreTeam=true'; * search: string = 'coreTeam=true';
* } * }
* *
* bootstrap(App, [HTTP_PROVIDERS, provide(RequestOptions, {asClass: MyOptions})]); * bootstrap(App, [HTTP_PROVIDERS, provide(RequestOptions, {useClass: MyOptions})]);
* ``` * ```
* *
* The options could also be extended when manually creating a {@link Request} * The options could also be extended when manually creating a {@link Request}

View File

@ -124,7 +124,7 @@ export class ResponseOptions {
* headers:Headers = new Headers({network: 'github'}); * headers:Headers = new Headers({network: 'github'});
* } * }
* *
* bootstrap(App, [HTTP_PROVIDERS, provide(ResponseOptions, {asClass: MyOptions})]); * bootstrap(App, [HTTP_PROVIDERS, provide(ResponseOptions, {useClass: MyOptions})]);
* ``` * ```
* *
* The options could also be extended when manually creating a {@link Response} * The options could also be extended when manually creating a {@link Response}

View File

@ -75,7 +75,7 @@ function mergeOptions(defaultOpts, providedOpts, method, url): RequestOptions {
* var injector = Injector.resolveAndCreate([ * var injector = Injector.resolveAndCreate([
* BaseRequestOptions, * BaseRequestOptions,
* MockBackend, * MockBackend,
* provide(Http, {asFactory: * provide(Http, {useFactory:
* function(backend, defaultOptions) { * function(backend, defaultOptions) {
* return new Http(backend, defaultOptions); * return new Http(backend, defaultOptions);
* }, * },

View File

@ -30,7 +30,7 @@ import {OpaqueToken, Injectable, Optional, Inject} from 'angular2/angular2';
* bootstrap(AppCmp, [ * bootstrap(AppCmp, [
* ROUTER_PROVIDERS, * ROUTER_PROVIDERS,
* PathLocationStrategy, * PathLocationStrategy,
* provide(APP_BASE_HREF, {asValue: '/my/app'}) * provide(APP_BASE_HREF, {useValue: '/my/app'})
* ]); * ]);
* ``` * ```
*/ */

View File

@ -44,7 +44,7 @@ import {LocationStrategy} from './location_strategy';
* *
* bootstrap(AppCmp, [ * bootstrap(AppCmp, [
* ROUTER_PROVIDERS, // includes binding to PathLocationStrategy * ROUTER_PROVIDERS, // includes binding to PathLocationStrategy
* provide(APP_BASE_HREF, {asValue: '/my/app'}) * provide(APP_BASE_HREF, {useValue: '/my/app'})
* ]); * ]);
* ``` * ```
*/ */

View File

@ -58,9 +58,9 @@ export class RouterOutlet {
var childRouter = this._parentRouter.childRouter(componentType); var childRouter = this._parentRouter.childRouter(componentType);
var providers = Injector.resolve([ var providers = Injector.resolve([
provide(ROUTE_DATA, {asValue: nextInstruction.routeData()}), provide(ROUTE_DATA, {useValue: nextInstruction.routeData()}),
provide(RouteParams, {asValue: new RouteParams(nextInstruction.params)}), provide(RouteParams, {useValue: new RouteParams(nextInstruction.params)}),
provide(routerMod.Router, {asValue: childRouter}) provide(routerMod.Router, {useValue: childRouter})
]); ]);
return this._loader.loadNextToLocation(componentType, this._elementRef, providers) return this._loader.loadNextToLocation(componentType, this._elementRef, providers)
.then((componentRef) => { .then((componentRef) => {

View File

@ -68,7 +68,7 @@ import {AppViewManager_} from "angular2/src/core/linker/view_manager";
* @returns {any[]} * @returns {any[]}
*/ */
function _getRootProviders() { function _getRootProviders() {
return [provide(Reflector, {asValue: reflector})]; return [provide(Reflector, {useValue: reflector})];
} }
/** /**
@ -91,36 +91,36 @@ function _getAppBindings() {
return [ return [
compilerProviders(), compilerProviders(),
provide(ChangeDetectorGenConfig, provide(ChangeDetectorGenConfig,
{asValue: new ChangeDetectorGenConfig(true, true, false, true)}), {useValue: new ChangeDetectorGenConfig(true, true, false, true)}),
provide(DOCUMENT, {asValue: appDoc}), provide(DOCUMENT, {useValue: appDoc}),
provide(DomRenderer, {asClass: DomRenderer_}), provide(DomRenderer, {useClass: DomRenderer_}),
provide(Renderer, {asAlias: DomRenderer}), provide(Renderer, {useExisting: DomRenderer}),
provide(APP_ID, {asValue: 'a'}), provide(APP_ID, {useValue: 'a'}),
DomSharedStylesHost, DomSharedStylesHost,
provide(SharedStylesHost, {asAlias: DomSharedStylesHost}), provide(SharedStylesHost, {useExisting: DomSharedStylesHost}),
AppViewPool, AppViewPool,
provide(AppViewManager, {asClass: AppViewManager_}), provide(AppViewManager, {useClass: AppViewManager_}),
AppViewManagerUtils, AppViewManagerUtils,
Serializer, Serializer,
ELEMENT_PROBE_PROVIDERS, ELEMENT_PROBE_PROVIDERS,
provide(APP_VIEW_POOL_CAPACITY, {asValue: 500}), provide(APP_VIEW_POOL_CAPACITY, {useValue: 500}),
ProtoViewFactory, ProtoViewFactory,
provide(DirectiveResolver, {asClass: MockDirectiveResolver}), provide(DirectiveResolver, {useClass: MockDirectiveResolver}),
provide(ViewResolver, {asClass: MockViewResolver}), provide(ViewResolver, {useClass: MockViewResolver}),
DEFAULT_PIPES, DEFAULT_PIPES,
provide(IterableDiffers, {asValue: defaultIterableDiffers}), provide(IterableDiffers, {useValue: defaultIterableDiffers}),
provide(KeyValueDiffers, {asValue: defaultKeyValueDiffers}), provide(KeyValueDiffers, {useValue: defaultKeyValueDiffers}),
Log, Log,
provide(DynamicComponentLoader, {asClass: DynamicComponentLoader_}), provide(DynamicComponentLoader, {useClass: DynamicComponentLoader_}),
PipeResolver, PipeResolver,
provide(ExceptionHandler, {asValue: new ExceptionHandler(DOM)}), provide(ExceptionHandler, {useValue: new ExceptionHandler(DOM)}),
provide(LocationStrategy, {asClass: MockLocationStrategy}), provide(LocationStrategy, {useClass: MockLocationStrategy}),
XHR, XHR,
TestComponentBuilder, TestComponentBuilder,
provide(NgZone, {asClass: MockNgZone}), provide(NgZone, {useClass: MockNgZone}),
provide(AnimationBuilder, {asClass: MockAnimationBuilder}), provide(AnimationBuilder, {useClass: MockAnimationBuilder}),
EventManager, EventManager,
new Provider(EVENT_MANAGER_PLUGINS, {toClass: DomEventsPlugin, multi: true}) new Provider(EVENT_MANAGER_PLUGINS, {useClass: DomEventsPlugin, multi: true})
]; ];
} }

View File

@ -117,8 +117,8 @@ export function beforeEach(fn: FunctionWithParamTokens | SyncTestFn): void {
* Example: * Example:
* *
* beforeEachBindings(() => [ * beforeEachBindings(() => [
* provide(Compiler, {asClass: MockCompiler}), * provide(Compiler, {useClass: MockCompiler}),
* provide(SomeToken, {asValue: myValue}), * provide(SomeToken, {useValue: myValue}),
* ]); * ]);
*/ */
export function beforeEachProviders(fn): void { export function beforeEachProviders(fn): void {
@ -148,7 +148,7 @@ function _it(jsmFn: Function, name: string, testFn: FunctionWithParamTokens | An
if (testFn.hasToken(AsyncTestCompleter)) { if (testFn.hasToken(AsyncTestCompleter)) {
jsmFn(name, (done) => { jsmFn(name, (done) => {
var completerProvider = provide(AsyncTestCompleter, { var completerProvider = provide(AsyncTestCompleter, {
asFactory: () => { useFactory: () => {
// Mark the test as async when an AsyncTestCompleter is injected in an it() // Mark the test as async when an AsyncTestCompleter is injected in an it()
if (!inIt) throw new Error('AsyncTestCompleter can only be injected in an "it()"'); if (!inIt) throw new Error('AsyncTestCompleter can only be injected in an "it()"');
return new AsyncTestCompleter(done); return new AsyncTestCompleter(done);

View File

@ -68,30 +68,30 @@ import {
var _rootInjector: Injector; var _rootInjector: Injector;
// Contains everything that is safe to share between applications. // Contains everything that is safe to share between applications.
var _rootProviders = [provide(Reflector, {asValue: reflector})]; var _rootProviders = [provide(Reflector, {useValue: reflector})];
// TODO: This code is nearly identical to core/application. There should be a way to only write it // TODO: This code is nearly identical to core/application. There should be a way to only write it
// once // once
function _injectorProviders(): any[] { function _injectorProviders(): any[] {
return [ return [
provide(DOCUMENT, {asValue: DOM.defaultDoc()}), provide(DOCUMENT, {useValue: DOM.defaultDoc()}),
EventManager, EventManager,
new Provider(EVENT_MANAGER_PLUGINS, {toClass: DomEventsPlugin, multi: true}), new Provider(EVENT_MANAGER_PLUGINS, {useClass: DomEventsPlugin, multi: true}),
new Provider(EVENT_MANAGER_PLUGINS, {toClass: KeyEventsPlugin, multi: true}), new Provider(EVENT_MANAGER_PLUGINS, {useClass: KeyEventsPlugin, multi: true}),
new Provider(EVENT_MANAGER_PLUGINS, {toClass: HammerGesturesPlugin, multi: true}), new Provider(EVENT_MANAGER_PLUGINS, {useClass: HammerGesturesPlugin, multi: true}),
provide(DomRenderer, {asClass: DomRenderer_}), provide(DomRenderer, {useClass: DomRenderer_}),
provide(Renderer, {asAlias: DomRenderer}), provide(Renderer, {useExisting: DomRenderer}),
APP_ID_RANDOM_PROVIDER, APP_ID_RANDOM_PROVIDER,
DomSharedStylesHost, DomSharedStylesHost,
provide(SharedStylesHost, {asAlias: DomSharedStylesHost}), provide(SharedStylesHost, {useExisting: DomSharedStylesHost}),
Serializer, Serializer,
provide(ON_WEB_WORKER, {asValue: false}), provide(ON_WEB_WORKER, {useValue: false}),
provide(ElementSchemaRegistry, {asValue: new DomElementSchemaRegistry()}), provide(ElementSchemaRegistry, {useValue: new DomElementSchemaRegistry()}),
RenderViewWithFragmentsStore, RenderViewWithFragmentsStore,
RenderProtoViewRefStore, RenderProtoViewRefStore,
AppViewPool, AppViewPool,
provide(APP_VIEW_POOL_CAPACITY, {asValue: 10000}), provide(APP_VIEW_POOL_CAPACITY, {useValue: 10000}),
provide(AppViewManager, {asClass: AppViewManager_}), provide(AppViewManager, {useClass: AppViewManager_}),
AppViewManagerUtils, AppViewManagerUtils,
AppViewListener, AppViewListener,
ProtoViewFactory, ProtoViewFactory,
@ -100,19 +100,19 @@ function _injectorProviders(): any[] {
DirectiveResolver, DirectiveResolver,
Parser, Parser,
Lexer, Lexer,
provide(ExceptionHandler, {asFactory: () => new ExceptionHandler(DOM), deps: []}), provide(ExceptionHandler, {useFactory: () => new ExceptionHandler(DOM), deps: []}),
provide(XHR, {asValue: new XHRImpl()}), provide(XHR, {useValue: new XHRImpl()}),
UrlResolver, UrlResolver,
provide(DynamicComponentLoader, {asClass: DynamicComponentLoader_}), provide(DynamicComponentLoader, {useClass: DynamicComponentLoader_}),
Testability, Testability,
AnchorBasedAppRootUrl, AnchorBasedAppRootUrl,
provide(AppRootUrl, {asAlias: AnchorBasedAppRootUrl}), provide(AppRootUrl, {useExisting: AnchorBasedAppRootUrl}),
WebWorkerApplication, WebWorkerApplication,
WebWorkerSetup, WebWorkerSetup,
MessageBasedXHRImpl, MessageBasedXHRImpl,
MessageBasedRenderer, MessageBasedRenderer,
provide(ServiceMessageBrokerFactory, {asClass: ServiceMessageBrokerFactory_}), provide(ServiceMessageBrokerFactory, {useClass: ServiceMessageBrokerFactory_}),
provide(ClientMessageBrokerFactory, {asClass: ClientMessageBrokerFactory_}), provide(ClientMessageBrokerFactory, {useClass: ClientMessageBrokerFactory_}),
BrowserDetails, BrowserDetails,
AnimationBuilder AnimationBuilder
]; ];
@ -120,8 +120,8 @@ function _injectorProviders(): any[] {
export function createInjector(zone: NgZone, bus: MessageBus): Injector { export function createInjector(zone: NgZone, bus: MessageBus): Injector {
BrowserDomAdapter.makeCurrent(); BrowserDomAdapter.makeCurrent();
_rootProviders.push(provide(NgZone, {asValue: zone})); _rootProviders.push(provide(NgZone, {useValue: zone}));
_rootProviders.push(provide(MessageBus, {asValue: bus})); _rootProviders.push(provide(MessageBus, {useValue: bus}));
var injector: Injector = Injector.resolveAndCreate(_rootProviders); var injector: Injector = Injector.resolveAndCreate(_rootProviders);
return injector.resolveAndCreateChild(_injectorProviders()); return injector.resolveAndCreateChild(_injectorProviders());
} }

View File

@ -96,18 +96,19 @@ function webWorkerProviders(appComponentType, bus: MessageBus, initData: {[key:
return [ return [
compilerProviders(), compilerProviders(),
Serializer, Serializer,
provide(MessageBus, {asValue: bus}), provide(MessageBus, {useValue: bus}),
provide(ClientMessageBrokerFactory, {asClass: ClientMessageBrokerFactory_}), provide(ClientMessageBrokerFactory, {useClass: ClientMessageBrokerFactory_}),
provide(ServiceMessageBrokerFactory, {asClass: ServiceMessageBrokerFactory_}), provide(ServiceMessageBrokerFactory, {useClass: ServiceMessageBrokerFactory_}),
WebWorkerRenderer, WebWorkerRenderer,
provide(Renderer, {asAlias: WebWorkerRenderer}), provide(Renderer, {useExisting: WebWorkerRenderer}),
provide(ON_WEB_WORKER, {asValue: true}), provide(ON_WEB_WORKER, {useValue: true}),
RenderViewWithFragmentsStore, RenderViewWithFragmentsStore,
RenderProtoViewRefStore, RenderProtoViewRefStore,
provide(ExceptionHandler, {asFactory: () => new ExceptionHandler(new PrintLogger()), deps: []}), provide(ExceptionHandler,
{useFactory: () => new ExceptionHandler(new PrintLogger()), deps: []}),
WebWorkerXHRImpl, WebWorkerXHRImpl,
provide(XHR, {asAlias: WebWorkerXHRImpl}), provide(XHR, {useExisting: WebWorkerXHRImpl}),
provide(AppRootUrl, {asValue: new AppRootUrl(initData['rootUrl'])}), provide(AppRootUrl, {useValue: new AppRootUrl(initData['rootUrl'])}),
WebWorkerEventDispatcher, WebWorkerEventDispatcher,
FORM_PROVIDERS FORM_PROVIDERS
]; ];

View File

@ -89,7 +89,7 @@ export function main() {
DOM.appendChild(fakeDoc.body, el2); DOM.appendChild(fakeDoc.body, el2);
DOM.appendChild(el, lightDom); DOM.appendChild(el, lightDom);
DOM.setText(lightDom, 'loading'); DOM.setText(lightDom, 'loading');
testProviders = [provide(DOCUMENT, {asValue: fakeDoc})]; testProviders = [provide(DOCUMENT, {useValue: fakeDoc})];
}); });
it('should throw if bootstrapped Directive is not a Component', it('should throw if bootstrapped Directive is not a Component',
@ -98,7 +98,7 @@ export function main() {
var exceptionHandler = new ExceptionHandler(logger, false); var exceptionHandler = new ExceptionHandler(logger, false);
var refPromise = var refPromise =
bootstrap(HelloRootDirectiveIsNotCmp, bootstrap(HelloRootDirectiveIsNotCmp,
[testProviders, provide(ExceptionHandler, {asValue: exceptionHandler})]); [testProviders, provide(ExceptionHandler, {useValue: exceptionHandler})]);
PromiseWrapper.then(refPromise, null, (exception) => { PromiseWrapper.then(refPromise, null, (exception) => {
expect(exception).toContainError( expect(exception).toContainError(
@ -114,7 +114,7 @@ export function main() {
var exceptionHandler = new ExceptionHandler(logger, IS_DART ? false : true); var exceptionHandler = new ExceptionHandler(logger, IS_DART ? false : true);
var refPromise = var refPromise =
bootstrap(HelloRootCmp, [provide(ExceptionHandler, {asValue: exceptionHandler})]); bootstrap(HelloRootCmp, [provide(ExceptionHandler, {useValue: exceptionHandler})]);
PromiseWrapper.then(refPromise, null, (reason) => { PromiseWrapper.then(refPromise, null, (reason) => {
expect(reason.message).toContain('The selector "hello-app" did not match any elements'); expect(reason.message).toContain('The selector "hello-app" did not match any elements');
async.done(); async.done();
@ -129,7 +129,7 @@ export function main() {
var exceptionHandler = new ExceptionHandler(logger, IS_DART ? false : true); var exceptionHandler = new ExceptionHandler(logger, IS_DART ? false : true);
var refPromise = var refPromise =
bootstrap(HelloRootCmp, [provide(ExceptionHandler, {asValue: exceptionHandler})]); bootstrap(HelloRootCmp, [provide(ExceptionHandler, {useValue: exceptionHandler})]);
PromiseWrapper.then(refPromise, null, (reason) => { PromiseWrapper.then(refPromise, null, (reason) => {
expect(logger.res.join("")) expect(logger.res.join(""))
.toContain('The selector "hello-app" did not match any elements'); .toContain('The selector "hello-app" did not match any elements');
@ -166,7 +166,7 @@ export function main() {
it("should make the provided bindings available to the application component", it("should make the provided bindings available to the application component",
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async) => {
var refPromise = bootstrap( var refPromise = bootstrap(
HelloRootCmp3, [testProviders, provide("appBinding", {asValue: "BoundValue"})]); HelloRootCmp3, [testProviders, provide("appBinding", {useValue: "BoundValue"})]);
refPromise.then((ref) => { refPromise.then((ref) => {
expect(ref.hostComponent.appBinding).toEqual("BoundValue"); expect(ref.hostComponent.appBinding).toEqual("BoundValue");

View File

@ -50,7 +50,7 @@ export function main() {
it('should extend di-inherited diffesr', () => { it('should extend di-inherited diffesr', () => {
var parent = new IterableDiffers([factory1]); var parent = new IterableDiffers([factory1]);
var injector = Injector.resolveAndCreate([provide(IterableDiffers, {asValue: parent})]); var injector = Injector.resolveAndCreate([provide(IterableDiffers, {useValue: parent})]);
var childInjector = injector.resolveAndCreateChild([IterableDiffers.extend([factory2])]); var childInjector = injector.resolveAndCreateChild([IterableDiffers.extend([factory2])]);
expect(injector.get(IterableDiffers).factories).toEqual([factory1]); expect(injector.get(IterableDiffers).factories).toEqual([factory1]);

View File

@ -84,7 +84,7 @@ export function main() {
describe('no jit', () => { describe('no jit', () => {
beforeEachBindings(() => [ beforeEachBindings(() => [
provide(ChangeDetectorGenConfig, provide(ChangeDetectorGenConfig,
{asValue: new ChangeDetectorGenConfig(true, true, false, false)}) {useValue: new ChangeDetectorGenConfig(true, true, false, false)})
]); ]);
it('should watch element properties', () => { it('should watch element properties', () => {
expect(detectChanges(compiler, '<div [el-prop]="someProp">')) expect(detectChanges(compiler, '<div [el-prop]="someProp">'))
@ -95,7 +95,7 @@ export function main() {
describe('jit', () => { describe('jit', () => {
beforeEachBindings(() => [ beforeEachBindings(() => [
provide(ChangeDetectorGenConfig, provide(ChangeDetectorGenConfig,
{asValue: new ChangeDetectorGenConfig(true, true, false, true)}) {useValue: new ChangeDetectorGenConfig(true, true, false, true)})
]); ]);
it('should watch element properties', () => { it('should watch element properties', () => {
expect(detectChanges(compiler, '<div [el-prop]="someProp">')) expect(detectChanges(compiler, '<div [el-prop]="someProp">'))

View File

@ -39,7 +39,7 @@ export function main() {
protoViewFactorySpy = new SpyProtoViewFactory(); protoViewFactorySpy = new SpyProtoViewFactory();
someProtoView = new AppProtoView(null, null, null, null, null, null); someProtoView = new AppProtoView(null, null, null, null, null, null);
protoViewFactorySpy.spy('createHost').andReturn(someProtoView); protoViewFactorySpy.spy('createHost').andReturn(someProtoView);
return [provide(ProtoViewFactory, {asValue: protoViewFactorySpy})]; return [provide(ProtoViewFactory, {useValue: protoViewFactorySpy})];
}); });
it('should compile the template via TemplateCompiler', it('should compile the template via TemplateCompiler',

View File

@ -51,7 +51,7 @@ export function main() {
beforeEachBindings(() => { beforeEachBindings(() => {
xhr = <any>new SpyXHR(); xhr = <any>new SpyXHR();
return [TEST_PROVIDERS, provide(XHR, {asValue: xhr})]; return [TEST_PROVIDERS, provide(XHR, {useValue: xhr})];
}); });
var compiler: StyleCompiler; var compiler: StyleCompiler;

View File

@ -64,7 +64,7 @@ export function main() {
var compiler: TemplateCompiler; var compiler: TemplateCompiler;
var runtimeMetadataResolver: RuntimeMetadataResolver; var runtimeMetadataResolver: RuntimeMetadataResolver;
beforeEachBindings(() => [provide(APP_ID, {asValue: APP_ID_VALUE}), TEST_PROVIDERS]); beforeEachBindings(() => [provide(APP_ID, {useValue: APP_ID_VALUE}), TEST_PROVIDERS]);
beforeEach(inject([TemplateCompiler, RuntimeMetadataResolver], beforeEach(inject([TemplateCompiler, RuntimeMetadataResolver],
(_compiler, _runtimeMetadataResolver) => { (_compiler, _runtimeMetadataResolver) => {
compiler = _compiler; compiler = _compiler;

View File

@ -51,7 +51,7 @@ export function main() {
TEST_PROVIDERS, TEST_PROVIDERS,
provide(ElementSchemaRegistry, provide(ElementSchemaRegistry,
{ {
asValue: new MockSchemaRegistry({'invalidProp': false}, useValue: new MockSchemaRegistry({'invalidProp': false},
{'mappedAttr': 'mappedProp'}) {'mappedAttr': 'mappedProp'})
}) })
]); ]);

View File

@ -5,6 +5,6 @@ import {MockXHR} from 'angular2/src/core/compiler/xhr_mock';
import {XHR} from 'angular2/src/core/compiler/xhr'; import {XHR} from 'angular2/src/core/compiler/xhr';
export var TEST_PROVIDERS = [ export var TEST_PROVIDERS = [
provide(ElementSchemaRegistry, {asValue: new MockSchemaRegistry({}, {})}), provide(ElementSchemaRegistry, {useValue: new MockSchemaRegistry({}, {})}),
provide(XHR, {asClass: MockXHR}) provide(XHR, {useClass: MockXHR})
]; ];

View File

@ -28,7 +28,7 @@ class MyComp {
export function main() { export function main() {
describe('element probe', function() { describe('element probe', function() {
beforeEachBindings(() => [provide(APP_VIEW_POOL_CAPACITY, {asValue: 0})]); beforeEachBindings(() => [provide(APP_VIEW_POOL_CAPACITY, {useValue: 0})]);
it('should return a TestElement from a dom element', it('should return a TestElement from a dom element',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {

View File

@ -90,17 +90,17 @@ class NoAnnotations {
export function main() { export function main() {
var dynamicProviders = [ var dynamicProviders = [
provide('provider0', {asValue: 1}), provide('provider0', {useValue: 1}),
provide('provider1', {asValue: 1}), provide('provider1', {useValue: 1}),
provide('provider2', {asValue: 1}), provide('provider2', {useValue: 1}),
provide('provider3', {asValue: 1}), provide('provider3', {useValue: 1}),
provide('provider4', {asValue: 1}), provide('provider4', {useValue: 1}),
provide('provider5', {asValue: 1}), provide('provider5', {useValue: 1}),
provide('provider6', {asValue: 1}), provide('provider6', {useValue: 1}),
provide('provider7', {asValue: 1}), provide('provider7', {useValue: 1}),
provide('provider8', {asValue: 1}), provide('provider8', {useValue: 1}),
provide('provider9', {asValue: 1}), provide('provider9', {useValue: 1}),
provide('provider10', {asValue: 1}) provide('provider10', {useValue: 1})
]; ];
[{strategy: 'inline', providers: [], strategyClass: InjectorInlineStrategy}, [{strategy: 'inline', providers: [], strategyClass: InjectorInlineStrategy},
@ -158,7 +158,7 @@ export function main() {
}); });
it('should provide to a value', () => { it('should provide to a value', () => {
var injector = createInjector([provide(Engine, {asValue: "fake engine"})]); var injector = createInjector([provide(Engine, {useValue: "fake engine"})]);
var engine = injector.get(Engine); var engine = injector.get(Engine);
expect(engine).toEqual("fake engine"); expect(engine).toEqual("fake engine");
@ -168,7 +168,7 @@ export function main() {
function sportsCarFactory(e) { return new SportsCar(e); } function sportsCarFactory(e) { return new SportsCar(e); }
var injector = var injector =
createInjector([Engine, provide(Car, {asFactory: sportsCarFactory, deps: [Engine]})]); createInjector([Engine, provide(Car, {useFactory: sportsCarFactory, deps: [Engine]})]);
var car = injector.get(Car); var car = injector.get(Car);
expect(car).toBeAnInstanceOf(SportsCar); expect(car).toBeAnInstanceOf(SportsCar);
@ -176,14 +176,17 @@ export function main() {
}); });
it('should supporting provider to null', () => { it('should supporting provider to null', () => {
var injector = createInjector([provide(Engine, {asValue: null})]); var injector = createInjector([provide(Engine, {useValue: null})]);
var engine = injector.get(Engine); var engine = injector.get(Engine);
expect(engine).toBeNull(); expect(engine).toBeNull();
}); });
it('should provide to an alias', () => { it('should provide to an alias', () => {
var injector = createInjector( var injector = createInjector([
[Engine, provide(SportsCar, {asClass: SportsCar}), provide(Car, {asAlias: SportsCar})]); Engine,
provide(SportsCar, {useClass: SportsCar}),
provide(Car, {useExisting: SportsCar})
]);
var car = injector.get(Car); var car = injector.get(Car);
var sportsCar = injector.get(SportsCar); var sportsCar = injector.get(SportsCar);
@ -194,8 +197,8 @@ export function main() {
it('should support multiProviders', () => { it('should support multiProviders', () => {
var injector = createInjector([ var injector = createInjector([
Engine, Engine,
new Provider(Car, {toClass: SportsCar, multi: true}), new Provider(Car, {useClass: SportsCar, multi: true}),
new Provider(Car, {toClass: CarWithOptionalEngine, multi: true}) new Provider(Car, {useClass: CarWithOptionalEngine, multi: true})
]); ]);
var cars = injector.get(Car); var cars = injector.get(Car);
@ -204,9 +207,9 @@ export function main() {
expect(cars[1]).toBeAnInstanceOf(CarWithOptionalEngine); expect(cars[1]).toBeAnInstanceOf(CarWithOptionalEngine);
}); });
it('should support multiProviders that are created using toAlias', () => { it('should support multiProviders that are created using useExisting', () => {
var injector = createInjector( var injector = createInjector(
[Engine, SportsCar, new Provider(Car, {toAlias: SportsCar, multi: true})]); [Engine, SportsCar, new Provider(Car, {useExisting: SportsCar, multi: true})]);
var cars = injector.get(Car); var cars = injector.get(Car);
expect(cars.length).toEqual(1); expect(cars.length).toEqual(1);
@ -214,22 +217,22 @@ export function main() {
}); });
it('should throw when the aliased provider does not exist', () => { it('should throw when the aliased provider does not exist', () => {
var injector = createInjector([provide('car', {asAlias: SportsCar})]); var injector = createInjector([provide('car', {useExisting: SportsCar})]);
var e = `No provider for ${stringify(SportsCar)}! (car -> ${stringify(SportsCar)})`; var e = `No provider for ${stringify(SportsCar)}! (car -> ${stringify(SportsCar)})`;
expect(() => injector.get('car')).toThrowError(e); expect(() => injector.get('car')).toThrowError(e);
}); });
it('should handle forwardRef in toAlias', () => { it('should handle forwardRef in useExisting', () => {
var injector = createInjector([ var injector = createInjector([
provide('originalEngine', {asClass: forwardRef(() => Engine)}), provide('originalEngine', {useClass: forwardRef(() => Engine)}),
provide('aliasedEngine', {asAlias:<any>forwardRef(() => 'originalEngine')}) provide('aliasedEngine', {useExisting:<any>forwardRef(() => 'originalEngine')})
]); ]);
expect(injector.get('aliasedEngine')).toBeAnInstanceOf(Engine); expect(injector.get('aliasedEngine')).toBeAnInstanceOf(Engine);
}); });
it('should support overriding factory dependencies', () => { it('should support overriding factory dependencies', () => {
var injector = createInjector( var injector = createInjector(
[Engine, provide(Car, {asFactory: (e) => new SportsCar(e), deps: [Engine]})]); [Engine, provide(Car, {useFactory: (e) => new SportsCar(e), deps: [Engine]})]);
var car = injector.get(Car); var car = injector.get(Car);
expect(car).toBeAnInstanceOf(SportsCar); expect(car).toBeAnInstanceOf(SportsCar);
@ -252,13 +255,13 @@ export function main() {
it("should use the last provider when there are multiple providers for same token", () => { it("should use the last provider when there are multiple providers for same token", () => {
var injector = createInjector( var injector = createInjector(
[provide(Engine, {asClass: Engine}), provide(Engine, {asClass: TurboEngine})]); [provide(Engine, {useClass: Engine}), provide(Engine, {useClass: TurboEngine})]);
expect(injector.get(Engine)).toBeAnInstanceOf(TurboEngine); expect(injector.get(Engine)).toBeAnInstanceOf(TurboEngine);
}); });
it('should use non-type tokens', () => { it('should use non-type tokens', () => {
var injector = createInjector([provide('token', {asValue: 'value'})]); var injector = createInjector([provide('token', {useValue: 'value'})]);
expect(injector.get('token')).toEqual('value'); expect(injector.get('token')).toEqual('value');
}); });
@ -289,7 +292,7 @@ export function main() {
}); });
it('should throw when trying to instantiate a cyclic dependency', () => { it('should throw when trying to instantiate a cyclic dependency', () => {
var injector = createInjector([Car, provide(Engine, {asClass: CyclicEngine})]); var injector = createInjector([Car, provide(Engine, {useClass: CyclicEngine})]);
expect(() => injector.get(Car)) expect(() => injector.get(Car))
.toThrowError( .toThrowError(
@ -297,7 +300,7 @@ export function main() {
}); });
it('should show the full path when error happens in a constructor', () => { it('should show the full path when error happens in a constructor', () => {
var providers = Injector.resolve([Car, provide(Engine, {asClass: BrokenEngine})]); var providers = Injector.resolve([Car, provide(Engine, {useClass: BrokenEngine})]);
var proto = new ProtoInjector([ var proto = new ProtoInjector([
new ProviderWithVisibility(providers[0], Visibility.Public), new ProviderWithVisibility(providers[0], Visibility.Public),
new ProviderWithVisibility(providers[1], Visibility.Public) new ProviderWithVisibility(providers[1], Visibility.Public)
@ -316,7 +319,7 @@ export function main() {
}); });
it('should provide context when throwing an exception ', () => { it('should provide context when throwing an exception ', () => {
var engineProvider = Injector.resolve([provide(Engine, {asClass: BrokenEngine})])[0]; var engineProvider = Injector.resolve([provide(Engine, {useClass: BrokenEngine})])[0];
var protoParent = var protoParent =
new ProtoInjector([new ProviderWithVisibility(engineProvider, Visibility.Public)]); new ProtoInjector([new ProviderWithVisibility(engineProvider, Visibility.Public)]);
@ -340,7 +343,7 @@ export function main() {
var injector = createInjector([ var injector = createInjector([
Car, Car,
provide(Engine, {asFactory: (() => isBroken ? new BrokenEngine() : new Engine())}) provide(Engine, {useFactory: (() => isBroken ? new BrokenEngine() : new Engine())})
]); ]);
expect(() => injector.get(Car)).toThrowError(new RegExp("Error")); expect(() => injector.get(Car)).toThrowError(new RegExp("Error"));
@ -351,7 +354,7 @@ export function main() {
}); });
it('should support null values', () => { it('should support null values', () => {
var injector = createInjector([provide('null', {asValue: null})]); var injector = createInjector([provide('null', {useValue: null})]);
expect(injector.get('null')).toBe(null); expect(injector.get('null')).toBe(null);
}); });
@ -388,7 +391,7 @@ export function main() {
it("should not use the child providers when resolving the dependencies of a parent provider", it("should not use the child providers when resolving the dependencies of a parent provider",
() => { () => {
var parent = Injector.resolveAndCreate([Car, Engine]); var parent = Injector.resolveAndCreate([Car, Engine]);
var child = parent.resolveAndCreateChild([provide(Engine, {asClass: TurboEngine})]); var child = parent.resolveAndCreateChild([provide(Engine, {useClass: TurboEngine})]);
var carFromChild = child.get(Car); var carFromChild = child.get(Car);
expect(carFromChild.engine).toBeAnInstanceOf(Engine); expect(carFromChild.engine).toBeAnInstanceOf(Engine);
@ -396,7 +399,7 @@ export function main() {
it('should create new instance in a child injector', () => { it('should create new instance in a child injector', () => {
var parent = Injector.resolveAndCreate([Engine]); var parent = Injector.resolveAndCreate([Engine]);
var child = parent.resolveAndCreateChild([provide(Engine, {asClass: TurboEngine})]); var child = parent.resolveAndCreateChild([provide(Engine, {useClass: TurboEngine})]);
var engineFromParent = parent.get(Engine); var engineFromParent = parent.get(Engine);
var engineFromChild = child.get(Engine); var engineFromChild = child.get(Engine);
@ -441,7 +444,7 @@ export function main() {
it("should return a dependency from self", () => { it("should return a dependency from self", () => {
var inj = Injector.resolveAndCreate([ var inj = Injector.resolveAndCreate([
Engine, Engine,
provide(Car, {asFactory: (e) => new Car(e), deps: [[Engine, new SelfMetadata()]]}) provide(Car, {useFactory: (e) => new Car(e), deps: [[Engine, new SelfMetadata()]]})
]); ]);
expect(inj.get(Car)).toBeAnInstanceOf(Car); expect(inj.get(Car)).toBeAnInstanceOf(Car);
@ -449,8 +452,9 @@ export function main() {
it("should throw when not requested provider on self", () => { it("should throw when not requested provider on self", () => {
var parent = Injector.resolveAndCreate([Engine]); var parent = Injector.resolveAndCreate([Engine]);
var child = parent.resolveAndCreateChild( var child = parent.resolveAndCreateChild([
[provide(Car, {asFactory: (e) => new Car(e), deps: [[Engine, new SelfMetadata()]]})]); provide(Car, {useFactory: (e) => new Car(e), deps: [[Engine, new SelfMetadata()]]})
]);
expect(() => child.get(Car)) expect(() => child.get(Car))
.toThrowError(`No provider for Engine! (${stringify(Car)} -> ${stringify(Engine)})`); .toThrowError(`No provider for Engine! (${stringify(Car)} -> ${stringify(Engine)})`);
@ -460,8 +464,9 @@ export function main() {
describe("@Host()", () => { describe("@Host()", () => {
it("should return a dependency from same host", () => { it("should return a dependency from same host", () => {
var parent = Injector.resolveAndCreate([Engine]); var parent = Injector.resolveAndCreate([Engine]);
var child = parent.resolveAndCreateChild( var child = parent.resolveAndCreateChild([
[provide(Car, {asFactory: (e) => new Car(e), deps: [[Engine, new HostMetadata()]]})]); provide(Car, {useFactory: (e) => new Car(e), deps: [[Engine, new HostMetadata()]]})
]);
expect(child.get(Car)).toBeAnInstanceOf(Car); expect(child.get(Car)).toBeAnInstanceOf(Car);
}); });
@ -472,8 +477,9 @@ export function main() {
new ProtoInjector([new ProviderWithVisibility(engine, Visibility.Private)]); new ProtoInjector([new ProviderWithVisibility(engine, Visibility.Private)]);
var parent = new Injector(protoParent); var parent = new Injector(protoParent);
var child = Injector.resolveAndCreate( var child = Injector.resolveAndCreate([
[provide(Car, {asFactory: (e) => new Car(e), deps: [[Engine, new HostMetadata()]]})]); provide(Car, {useFactory: (e) => new Car(e), deps: [[Engine, new HostMetadata()]]})
]);
child.internalStrategy.attach(parent, true); // host child.internalStrategy.attach(parent, true); // host
@ -486,8 +492,9 @@ export function main() {
new ProtoInjector([new ProviderWithVisibility(engine, Visibility.Public)]); new ProtoInjector([new ProviderWithVisibility(engine, Visibility.Public)]);
var parent = new Injector(protoParent); var parent = new Injector(protoParent);
var child = Injector.resolveAndCreate( var child = Injector.resolveAndCreate([
[provide(Car, {asFactory: (e) => new Car(e), deps: [[Engine, new HostMetadata()]]})]); provide(Car, {useFactory: (e) => new Car(e), deps: [[Engine, new HostMetadata()]]})
]);
child.internalStrategy.attach(parent, true); // host child.internalStrategy.attach(parent, true); // host
@ -498,8 +505,8 @@ export function main() {
it("should not skip self", () => { it("should not skip self", () => {
var parent = Injector.resolveAndCreate([Engine]); var parent = Injector.resolveAndCreate([Engine]);
var child = parent.resolveAndCreateChild([ var child = parent.resolveAndCreateChild([
provide(Engine, {asClass: TurboEngine}), provide(Engine, {useClass: TurboEngine}),
provide(Car, {asFactory: (e) => new Car(e), deps: [[Engine, new HostMetadata()]]}) provide(Car, {useFactory: (e) => new Car(e), deps: [[Engine, new HostMetadata()]]})
]); ]);
expect(child.get(Car).engine).toBeAnInstanceOf(TurboEngine); expect(child.get(Car).engine).toBeAnInstanceOf(TurboEngine);
@ -514,9 +521,9 @@ export function main() {
var parent = new Injector(protoParent); var parent = new Injector(protoParent);
var child = Injector.resolveAndCreate([ var child = Injector.resolveAndCreate([
provide(Engine, {asClass: BrokenEngine}), provide(Engine, {useClass: BrokenEngine}),
provide(Car, provide(Car,
{asFactory: (e) => new Car(e), deps: [[Engine, new SkipSelfMetadata()]]}) {useFactory: (e) => new Car(e), deps: [[Engine, new SkipSelfMetadata()]]})
]); ]);
child.internalStrategy.attach(parent, true); // boundary child.internalStrategy.attach(parent, true); // boundary
@ -530,9 +537,9 @@ export function main() {
var parent = new Injector(protoParent); var parent = new Injector(protoParent);
var child = Injector.resolveAndCreate([ var child = Injector.resolveAndCreate([
provide(Engine, {asClass: BrokenEngine}), provide(Engine, {useClass: BrokenEngine}),
provide(Car, provide(Car,
{asFactory: (e) => new Car(e), deps: [[Engine, new SkipSelfMetadata()]]}) {useFactory: (e) => new Car(e), deps: [[Engine, new SkipSelfMetadata()]]})
]); ]);
child.internalStrategy.attach(parent, true); // boundary child.internalStrategy.attach(parent, true); // boundary
@ -546,9 +553,9 @@ export function main() {
var parent = new Injector(protoParent); var parent = new Injector(protoParent);
var child = Injector.resolveAndCreate([ var child = Injector.resolveAndCreate([
provide(Engine, {asClass: BrokenEngine}), provide(Engine, {useClass: BrokenEngine}),
provide(Car, provide(Car,
{asFactory: (e) => new Car(e), deps: [[Engine, new SkipSelfMetadata()]]}) {useFactory: (e) => new Car(e), deps: [[Engine, new SkipSelfMetadata()]]})
]); ]);
child.internalStrategy.attach(parent, false); child.internalStrategy.attach(parent, false);
@ -559,8 +566,8 @@ export function main() {
it("should not skip self", () => { it("should not skip self", () => {
var parent = Injector.resolveAndCreate([Engine]); var parent = Injector.resolveAndCreate([Engine]);
var child = parent.resolveAndCreateChild([ var child = parent.resolveAndCreateChild([
provide(Engine, {asClass: TurboEngine}), provide(Engine, {useClass: TurboEngine}),
provide(Car, {asFactory: (e) => new Car(e), deps: [Engine]}) provide(Car, {useFactory: (e) => new Car(e), deps: [Engine]})
]); ]);
expect(child.get(Car).engine).toBeAnInstanceOf(TurboEngine); expect(child.get(Car).engine).toBeAnInstanceOf(TurboEngine);
@ -579,8 +586,8 @@ export function main() {
it("should support multi providers", () => { it("should support multi providers", () => {
var provider = Injector.resolve([ var provider = Injector.resolve([
new Provider(Engine, {toClass: BrokenEngine, multi: true}), new Provider(Engine, {useClass: BrokenEngine, multi: true}),
new Provider(Engine, {toClass: TurboEngine, multi: true}) new Provider(Engine, {useClass: TurboEngine, multi: true})
])[0]; ])[0];
expect(provider.key.token).toBe(Engine); expect(provider.key.token).toBe(Engine);
@ -590,7 +597,7 @@ export function main() {
it("should support multi providers with only one provider", () => { it("should support multi providers with only one provider", () => {
var provider = var provider =
Injector.resolve([new Provider(Engine, {toClass: BrokenEngine, multi: true})])[0]; Injector.resolve([new Provider(Engine, {useClass: BrokenEngine, multi: true})])[0];
expect(provider.key.token).toBe(Engine); expect(provider.key.token).toBe(Engine);
expect(provider.multiProvider).toEqual(true); expect(provider.multiProvider).toEqual(true);
@ -599,20 +606,20 @@ export function main() {
it("should throw when mixing multi providers with regular providers", () => { it("should throw when mixing multi providers with regular providers", () => {
expect(() => { expect(() => {
Injector.resolve([new Provider(Engine, {toClass: BrokenEngine, multi: true}), Engine]); Injector.resolve([new Provider(Engine, {useClass: BrokenEngine, multi: true}), Engine]);
}).toThrowErrorWith("Cannot mix multi providers and regular providers"); }).toThrowErrorWith("Cannot mix multi providers and regular providers");
expect(() => { expect(() => {
Injector.resolve([Engine, new Provider(Engine, {toClass: BrokenEngine, multi: true})]); Injector.resolve([Engine, new Provider(Engine, {useClass: BrokenEngine, multi: true})]);
}).toThrowErrorWith("Cannot mix multi providers and regular providers"); }).toThrowErrorWith("Cannot mix multi providers and regular providers");
}); });
it('should resolve forward references', () => { it('should resolve forward references', () => {
var providers = Injector.resolve([ var providers = Injector.resolve([
forwardRef(() => Engine), forwardRef(() => Engine),
[provide(forwardRef(() => BrokenEngine), {asClass: forwardRef(() => Engine)})], [provide(forwardRef(() => BrokenEngine), {useClass: forwardRef(() => Engine)})],
provide(forwardRef(() => String), provide(forwardRef(() => String),
{asFactory: () => 'OK', deps: [forwardRef(() => Engine)]}) {useFactory: () => 'OK', deps: [forwardRef(() => Engine)]})
]); ]);
var engineProvider = providers[0]; var engineProvider = providers[0];
@ -628,7 +635,7 @@ export function main() {
var providers = Injector.resolve([ var providers = Injector.resolve([
provide("token", provide("token",
{ {
asFactory: (e) => "result", useFactory: (e) => "result",
deps: [[new InjectMetadata("dep"), new CustomDependencyMetadata()]] deps: [[new InjectMetadata("dep"), new CustomDependencyMetadata()]]
}) })
]); ]);

View File

@ -29,7 +29,7 @@ export function main() {
describe('binding to CSS class list', () => { describe('binding to CSS class list', () => {
describe('viewpool support', () => { describe('viewpool support', () => {
beforeEachBindings(() => { return [provide(APP_VIEW_POOL_CAPACITY, {asValue: 100})]; }); beforeEachBindings(() => { return [provide(APP_VIEW_POOL_CAPACITY, {useValue: 100})]; });
it('should clean up when the directive is destroyed', it('should clean up when the directive is destroyed',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {

View File

@ -37,8 +37,8 @@ export function main() {
protoViewFactorySpy = new SpyProtoViewFactory(); protoViewFactorySpy = new SpyProtoViewFactory();
someProtoView = new AppProtoView(null, null, null, null, null, null); someProtoView = new AppProtoView(null, null, null, null, null, null);
protoViewFactorySpy.spy('createHost').andReturn(someProtoView); protoViewFactorySpy.spy('createHost').andReturn(someProtoView);
var factory = provide(ProtoViewFactory, {asValue: protoViewFactorySpy}); var factory = provide(ProtoViewFactory, {useValue: protoViewFactorySpy});
var classProvider = provide(Compiler, {asClass: Compiler_}); var classProvider = provide(Compiler, {useClass: Compiler_});
var providers = [factory, classProvider]; var providers = [factory, classProvider];
return providers; return providers;
}); });

View File

@ -232,7 +232,7 @@ export function main() {
var dynamicProviders = []; var dynamicProviders = [];
for (var i = 0; i < 20; i++) { for (var i = 0; i < 20; i++) {
dynamicProviders.push(provide(i, {asValue: i})); dynamicProviders.push(provide(i, {useValue: i}));
} }
function createPei(parent, index, providers: any[], distance = 1, hasShadowRoot = false, dirVariableBindings = null) { function createPei(parent, index, providers: any[], distance = 1, hasShadowRoot = false, dirVariableBindings = null) {
@ -322,7 +322,7 @@ export function main() {
describe('inline strategy', () => { describe('inline strategy', () => {
it("should allow for direct access using getProviderAtIndex", () => { it("should allow for direct access using getProviderAtIndex", () => {
var proto = createPei(null, 0, [provide(SimpleDirective, {asClass: SimpleDirective})]); var proto = createPei(null, 0, [provide(SimpleDirective, {useClass: SimpleDirective})]);
expect(proto.getProviderAtIndex(0)).toBeAnInstanceOf(DirectiveProvider); expect(proto.getProviderAtIndex(0)).toBeAnInstanceOf(DirectiveProvider);
expect(() => proto.getProviderAtIndex(-1)).toThrowError('Index -1 is out-of-bounds.'); expect(() => proto.getProviderAtIndex(-1)).toThrowError('Index -1 is out-of-bounds.');
@ -373,9 +373,9 @@ export function main() {
var pei = createPei(null, 0, [ var pei = createPei(null, 0, [
DirectiveProvider.createFromType( DirectiveProvider.createFromType(
SimpleDirective, SimpleDirective,
new ComponentMetadata({providers: [provide('injectable1', {asValue: 'injectable1'})]})), new ComponentMetadata({providers: [provide('injectable1', {useValue: 'injectable1'})]})),
DirectiveProvider.createFromType(SomeOtherDirective, new ComponentMetadata({ DirectiveProvider.createFromType(SomeOtherDirective, new ComponentMetadata({
providers: [provide('injectable2', {asValue: 'injectable2'})] providers: [provide('injectable2', {useValue: 'injectable2'})]
})) }))
]); ]);
@ -388,7 +388,7 @@ export function main() {
it("should collect view providers from the component", () => { it("should collect view providers from the component", () => {
var pei = createPei(null, 0, var pei = createPei(null, 0,
[DirectiveProvider.createFromType(SimpleDirective, new ComponentMetadata({ [DirectiveProvider.createFromType(SimpleDirective, new ComponentMetadata({
viewProviders: [provide('injectable1', {asValue: 'injectable1'})] viewProviders: [provide('injectable1', {useValue: 'injectable1'})]
}))], }))],
0, true); 0, true);
@ -401,8 +401,8 @@ export function main() {
DirectiveProvider.createFromType( DirectiveProvider.createFromType(
SimpleDirective, SimpleDirective,
new ComponentMetadata({ new ComponentMetadata({
viewProviders: [[[provide('view', {asValue: 'view'})]]], viewProviders: [[[provide('view', {useValue: 'view'})]]],
providers: [[[provide('host', {asValue: 'host'})]]] providers: [[[provide('host', {useValue: 'host'})]]]
})) }))
], 0, true); ], 0, true);
@ -510,13 +510,13 @@ export function main() {
var childInj = parentChildInjectors( var childInj = parentChildInjectors(
ListWrapper.concat( ListWrapper.concat(
[DirectiveProvider.createFromType(SimpleDirective, new ComponentMetadata({ [DirectiveProvider.createFromType(SimpleDirective, new ComponentMetadata({
providers: [provide('injectable1', {asValue: 'injectable1'})] providers: [provide('injectable1', {useValue: 'injectable1'})]
}))], }))],
extraProviders), extraProviders),
[DirectiveProvider.createFromType(SimpleDirective, new ComponentMetadata({ [DirectiveProvider.createFromType(SimpleDirective, new ComponentMetadata({
providers: [ providers: [
provide('injectable1', {asValue:'new-injectable1'}), provide('injectable1', {useValue:'new-injectable1'}),
provide('injectable2', {asFactory: provide('injectable2', {useFactory:
(val) => `${val}-injectable2`, (val) => `${val}-injectable2`,
deps: [[new InjectMetadata('injectable1'), new SkipSelfMetadata()]]}) deps: [[new InjectMetadata('injectable1'), new SkipSelfMetadata()]]})
] ]
@ -526,8 +526,8 @@ export function main() {
it("should instantiate providers that have dependencies", () => { it("should instantiate providers that have dependencies", () => {
var providers = [ var providers = [
provide('injectable1', {asValue: 'injectable1'}), provide('injectable1', {useValue: 'injectable1'}),
provide('injectable2', {asFactory: provide('injectable2', {useFactory:
(val) => `${val}-injectable2`, (val) => `${val}-injectable2`,
deps: ['injectable1']}) deps: ['injectable1']})
]; ];
@ -542,8 +542,8 @@ export function main() {
it("should instantiate viewProviders that have dependencies", () => { it("should instantiate viewProviders that have dependencies", () => {
var viewProviders = [ var viewProviders = [
provide('injectable1', {asValue: 'injectable1'}), provide('injectable1', {useValue: 'injectable1'}),
provide('injectable2', {asFactory: provide('injectable2', {useFactory:
(val) => `${val}-injectable2`, (val) => `${val}-injectable2`,
deps: ['injectable1']}) deps: ['injectable1']})
]; ];
@ -559,7 +559,7 @@ export function main() {
it("should instantiate components that depend on viewProviders providers", () => { it("should instantiate components that depend on viewProviders providers", () => {
var inj = injector( var inj = injector(
ListWrapper.concat([DirectiveProvider.createFromType(NeedsService, new ComponentMetadata({ ListWrapper.concat([DirectiveProvider.createFromType(NeedsService, new ComponentMetadata({
viewProviders: [provide('service', {asValue: 'service'})] viewProviders: [provide('service', {useValue: 'service'})]
}))], }))],
extraProviders), extraProviders),
null, true); null, true);
@ -570,7 +570,7 @@ export function main() {
var created = false; var created = false;
var inj = injector( var inj = injector(
ListWrapper.concat([DirectiveProvider.createFromType(SimpleDirective, new ComponentMetadata({ ListWrapper.concat([DirectiveProvider.createFromType(SimpleDirective, new ComponentMetadata({
providers: [provide('service', {asFactory: () => created = true})] providers: [provide('service', {useFactory: () => created = true})]
}))], }))],
extraProviders), extraProviders),
null, true); null, true);
@ -586,7 +586,7 @@ export function main() {
var created = false; var created = false;
var inj = injector( var inj = injector(
ListWrapper.concat([DirectiveProvider.createFromType(SimpleDirective, new ComponentMetadata({ ListWrapper.concat([DirectiveProvider.createFromType(SimpleDirective, new ComponentMetadata({
viewProviders: [provide('service', {asFactory: () => created = true})] viewProviders: [provide('service', {useFactory: () => created = true})]
}))], }))],
extraProviders), extraProviders),
null, true); null, true);
@ -601,7 +601,7 @@ export function main() {
it("should not instantiate other directives that depend on viewProviders providers", it("should not instantiate other directives that depend on viewProviders providers",
() => { () => {
var directiveAnnotation = new ComponentMetadata({ var directiveAnnotation = new ComponentMetadata({
viewProviders: ListWrapper.concat([provide("service", {asValue: "service"})], extraProviders) viewProviders: ListWrapper.concat([provide("service", {useValue: "service"})], extraProviders)
}); });
var componentDirective = var componentDirective =
DirectiveProvider.createFromType(SimpleDirective, directiveAnnotation); DirectiveProvider.createFromType(SimpleDirective, directiveAnnotation);
@ -613,7 +613,7 @@ export function main() {
it("should instantiate directives that depend on providers of other directives", () => { it("should instantiate directives that depend on providers of other directives", () => {
var shadowInj = hostShadowInjectors( var shadowInj = hostShadowInjectors(
ListWrapper.concat([DirectiveProvider.createFromType(SimpleDirective, new ComponentMetadata({ ListWrapper.concat([DirectiveProvider.createFromType(SimpleDirective, new ComponentMetadata({
providers: [provide('service', {asValue: 'hostService'})]}) providers: [provide('service', {useValue: 'hostService'})]})
)], extraProviders), )], extraProviders),
ListWrapper.concat([NeedsService], extraProviders) ListWrapper.concat([NeedsService], extraProviders)
); );
@ -622,7 +622,7 @@ export function main() {
it("should instantiate directives that depend on imperatively created injector providers (bootstrap)", () => { it("should instantiate directives that depend on imperatively created injector providers (bootstrap)", () => {
var imperativelyCreatedInjector = Injector.resolveAndCreate([ var imperativelyCreatedInjector = Injector.resolveAndCreate([
provide("service", {asValue: 'appService'}) provide("service", {useValue: 'appService'})
]); ]);
var inj = injector([NeedsService], imperativelyCreatedInjector); var inj = injector([NeedsService], imperativelyCreatedInjector);
expect(inj.get(NeedsService).service).toEqual('appService'); expect(inj.get(NeedsService).service).toEqual('appService');
@ -632,7 +632,7 @@ export function main() {
it("should instantiate directives that depend on imperatively created injector providers (root injector)", () => { it("should instantiate directives that depend on imperatively created injector providers (root injector)", () => {
var imperativelyCreatedInjector = Injector.resolveAndCreate([ var imperativelyCreatedInjector = Injector.resolveAndCreate([
provide("service", {asValue: 'appService'}) provide("service", {useValue: 'appService'})
]); ]);
var inj = hostShadowInjectors([SimpleDirective], [NeedsService, NeedsServiceFromHost], imperativelyCreatedInjector); var inj = hostShadowInjectors([SimpleDirective], [NeedsService, NeedsServiceFromHost], imperativelyCreatedInjector);
expect(inj.get(NeedsService).service).toEqual('appService'); expect(inj.get(NeedsService).service).toEqual('appService');
@ -641,7 +641,7 @@ export function main() {
it("should instantiate directives that depend on imperatively created injector providers (child injector)", () => { it("should instantiate directives that depend on imperatively created injector providers (child injector)", () => {
var imperativelyCreatedInjector = Injector.resolveAndCreate([ var imperativelyCreatedInjector = Injector.resolveAndCreate([
provide("service", {asValue: 'appService'}) provide("service", {useValue: 'appService'})
]); ]);
var inj = parentChildInjectors([], [NeedsService, NeedsServiceFromHost], null, imperativelyCreatedInjector); var inj = parentChildInjectors([], [NeedsService, NeedsServiceFromHost], null, imperativelyCreatedInjector);
expect(inj.get(NeedsService).service).toEqual('appService'); expect(inj.get(NeedsService).service).toEqual('appService');
@ -651,17 +651,17 @@ export function main() {
it("should prioritize viewProviders over providers for the same provider", () => { it("should prioritize viewProviders over providers for the same provider", () => {
var inj = injector( var inj = injector(
ListWrapper.concat([DirectiveProvider.createFromType(NeedsService, new ComponentMetadata({ ListWrapper.concat([DirectiveProvider.createFromType(NeedsService, new ComponentMetadata({
providers: [provide('service', {asValue: 'hostService'})], providers: [provide('service', {useValue: 'hostService'})],
viewProviders: [provide('service', {asValue: 'viewService'})]}) viewProviders: [provide('service', {useValue: 'viewService'})]})
)], extraProviders), null, true); )], extraProviders), null, true);
expect(inj.get(NeedsService).service).toEqual('viewService'); expect(inj.get(NeedsService).service).toEqual('viewService');
}); });
it("should prioritize directive providers over component providers", () => { it("should prioritize directive providers over component providers", () => {
var component = DirectiveProvider.createFromType(NeedsService, new ComponentMetadata({ var component = DirectiveProvider.createFromType(NeedsService, new ComponentMetadata({
providers: [provide('service', {asValue: 'compService'})]})); providers: [provide('service', {useValue: 'compService'})]}));
var directive = DirectiveProvider.createFromType(SomeOtherDirective, new DirectiveMetadata({ var directive = DirectiveProvider.createFromType(SomeOtherDirective, new DirectiveMetadata({
providers: [provide('service', {asValue: 'dirService'})]})); providers: [provide('service', {useValue: 'dirService'})]}));
var inj = injector(ListWrapper.concat([component, directive], extraProviders), null, true); var inj = injector(ListWrapper.concat([component, directive], extraProviders), null, true);
expect(inj.get(NeedsService).service).toEqual('dirService'); expect(inj.get(NeedsService).service).toEqual('dirService');
}); });
@ -672,7 +672,7 @@ export function main() {
hostShadowInjectors( hostShadowInjectors(
ListWrapper.concat([ ListWrapper.concat([
DirectiveProvider.createFromType(SomeOtherDirective, new DirectiveMetadata({ DirectiveProvider.createFromType(SomeOtherDirective, new DirectiveMetadata({
providers: [provide('service', {asValue: 'hostService'})]}) providers: [provide('service', {useValue: 'hostService'})]})
)], extraProviders), )], extraProviders),
ListWrapper.concat([NeedsServiceFromHost], extraProviders) ListWrapper.concat([NeedsServiceFromHost], extraProviders)
); );
@ -686,7 +686,7 @@ export function main() {
ListWrapper.concat([ ListWrapper.concat([
SimpleDirective, SimpleDirective,
DirectiveProvider.createFromType(SomeOtherDirective, new DirectiveMetadata({ DirectiveProvider.createFromType(SomeOtherDirective, new DirectiveMetadata({
providers: [provide('service', {asValue: 'hostService'})]}) providers: [provide('service', {useValue: 'hostService'})]})
)], extraProviders), )], extraProviders),
ListWrapper.concat([NeedsServiceFromHost], extraProviders) ListWrapper.concat([NeedsServiceFromHost], extraProviders)
@ -737,13 +737,13 @@ export function main() {
it("should accept providers instead of types", () => { it("should accept providers instead of types", () => {
var inj = injector( var inj = injector(
ListWrapper.concat([provide(SimpleDirective, {asClass: SimpleDirective})], extraProviders)); ListWrapper.concat([provide(SimpleDirective, {useClass: SimpleDirective})], extraProviders));
expect(inj.get(SimpleDirective)).toBeAnInstanceOf(SimpleDirective); expect(inj.get(SimpleDirective)).toBeAnInstanceOf(SimpleDirective);
}); });
it("should allow for direct access using getDirectiveAtIndex", () => { it("should allow for direct access using getDirectiveAtIndex", () => {
var providers = var providers =
ListWrapper.concat([provide(SimpleDirective, {asClass: SimpleDirective})], extraProviders); ListWrapper.concat([provide(SimpleDirective, {useClass: SimpleDirective})], extraProviders);
var inj = injector(providers); var inj = injector(providers);

View File

@ -97,7 +97,7 @@ const ANCHOR_ELEMENT = CONST_EXPR(new OpaqueToken('AnchorElement'));
export function main() { export function main() {
describe('integration tests', function() { describe('integration tests', function() {
beforeEachBindings(() => [provide(ANCHOR_ELEMENT, {asValue: el('<div></div>')})]); beforeEachBindings(() => [provide(ANCHOR_ELEMENT, {useValue: el('<div></div>')})]);
describe('react to record changes', function() { describe('react to record changes', function() {
it('should consume text node changes', it('should consume text node changes',
@ -1517,7 +1517,7 @@ export function main() {
describe('logging property updates', () => { describe('logging property updates', () => {
beforeEachBindings(() => [ beforeEachBindings(() => [
provide(ChangeDetectorGenConfig, provide(ChangeDetectorGenConfig,
{asValue: new ChangeDetectorGenConfig(true, true, true, false)}) {useValue: new ChangeDetectorGenConfig(true, true, true, false)})
]); ]);
it('should reflect property values as attributes', it('should reflect property values as attributes',
@ -1741,7 +1741,7 @@ class DynamicViewport {
var myService = new MyService(); var myService = new MyService();
myService.greeting = 'dynamic greet'; myService.greeting = 'dynamic greet';
var bindings = Injector.resolve([provide(MyService, {asValue: myService})]); var bindings = Injector.resolve([provide(MyService, {useValue: myService})]);
this.done = compiler.compileInHost(ChildCompUsingService) this.done = compiler.compileInHost(ChildCompUsingService)
.then((hostPv) => {vc.createHostView(hostPv, 0, bindings)}); .then((hostPv) => {vc.createHostView(hostPv, 0, bindings)});
} }
@ -2026,7 +2026,7 @@ class PublicApi {
@Directive({ @Directive({
selector: '[public-api]', selector: '[public-api]',
providers: [new Provider(PublicApi, {toAlias: PrivateImpl, deps: []})] providers: [new Provider(PublicApi, {useExisting: PrivateImpl, deps: []})]
}) })
@Injectable() @Injectable()
class PrivateImpl extends PublicApi { class PrivateImpl extends PublicApi {
@ -2094,7 +2094,7 @@ function createInjectableWithLogging(inj: Injector) {
@Component({ @Component({
selector: 'component-providing-logging-injectable', selector: 'component-providing-logging-injectable',
providers: [ providers: [
new Provider(InjectableService, {toFactory: createInjectableWithLogging, deps: [Injector]}) new Provider(InjectableService, {useFactory: createInjectableWithLogging, deps: [Injector]})
] ]
}) })
@View({template: ''}) @View({template: ''})
@ -2117,8 +2117,8 @@ class DirectiveProvidingInjectableInView {
@Component({ @Component({
selector: 'directive-providing-injectable', selector: 'directive-providing-injectable',
providers: [new Provider(InjectableService, {toValue: 'host'})], providers: [new Provider(InjectableService, {useValue: 'host'})],
viewProviders: [new Provider(InjectableService, {toValue: 'view'})] viewProviders: [new Provider(InjectableService, {useValue: 'view'})]
}) })
@View({template: ''}) @View({template: ''})
@Injectable() @Injectable()
@ -2170,7 +2170,7 @@ class EventBus {
@Directive({ @Directive({
selector: 'grand-parent-providing-event-bus', selector: 'grand-parent-providing-event-bus',
providers: [new Provider(EventBus, {toValue: new EventBus(null, "grandparent")})] providers: [new Provider(EventBus, {useValue: new EventBus(null, "grandparent")})]
}) })
class GrandParentProvidingEventBus { class GrandParentProvidingEventBus {
bus: EventBus; bus: EventBus;
@ -2186,7 +2186,7 @@ function createParentBus(peb) {
selector: 'parent-providing-event-bus', selector: 'parent-providing-event-bus',
providers: [ providers: [
new Provider(EventBus, new Provider(EventBus,
{toFactory: createParentBus, deps: [[EventBus, new SkipSelfMetadata()]]}) {useFactory: createParentBus, deps: [[EventBus, new SkipSelfMetadata()]]})
] ]
}) })
@View({ @View({

View File

@ -40,7 +40,7 @@ import {By} from 'angular2/src/core/debug';
export function main() { export function main() {
describe('projection', () => { describe('projection', () => {
beforeEachBindings(() => [provide(AppViewListener, {asClass: AppViewListener})]); beforeEachBindings(() => [provide(AppViewListener, {useClass: AppViewListener})]);
it('should support simple components', it('should support simple components',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {

View File

@ -30,8 +30,9 @@ export function main() {
describe("Pipes", () => { describe("Pipes", () => {
var injector; var injector;
beforeEach( beforeEach(() => {
() => { injector = Injector.resolveAndCreate([provide('dep', {asValue: 'dependency'})]); }); injector = Injector.resolveAndCreate([provide('dep', {useValue: 'dependency'})]);
});
it('should instantiate a pipe', () => { it('should instantiate a pipe', () => {
var proto = var proto =

View File

@ -72,9 +72,9 @@ export function main() {
beforeEach(() => { beforeEach(() => {
let injector = Injector.resolveAndCreate([ let injector = Injector.resolveAndCreate([
provide(ResponseOptions, {asClass: BaseResponseOptions}), provide(ResponseOptions, {useClass: BaseResponseOptions}),
provide(BrowserJsonp, {asClass: MockBrowserJsonp}), provide(BrowserJsonp, {useClass: MockBrowserJsonp}),
provide(JSONPBackend, {asClass: JSONPBackend_}) provide(JSONPBackend, {useClass: JSONPBackend_})
]); ]);
backend = injector.get(JSONPBackend); backend = injector.get(JSONPBackend);
let base = new BaseRequestOptions(); let base = new BaseRequestOptions();

View File

@ -35,7 +35,7 @@ export function main() {
beforeEach(() => { beforeEach(() => {
var injector = Injector.resolveAndCreate( var injector = Injector.resolveAndCreate(
[provide(ResponseOptions, {asClass: BaseResponseOptions}), MockBackend]); [provide(ResponseOptions, {useClass: BaseResponseOptions}), MockBackend]);
backend = injector.get(MockBackend); backend = injector.get(MockBackend);
var base = new BaseRequestOptions(); var base = new BaseRequestOptions();
sampleRequest1 = new Request(base.merge(new RequestOptions({url: 'https://google.com'}))); sampleRequest1 = new Request(base.merge(new RequestOptions({url: 'https://google.com'})));

View File

@ -75,8 +75,8 @@ export function main() {
beforeEach(() => { beforeEach(() => {
var injector = Injector.resolveAndCreate([ var injector = Injector.resolveAndCreate([
provide(ResponseOptions, {asClass: BaseResponseOptions}), provide(ResponseOptions, {useClass: BaseResponseOptions}),
provide(BrowserXhr, {asClass: MockBrowserXHR}), provide(BrowserXhr, {useClass: MockBrowserXHR}),
XHRBackend XHRBackend
]); ]);
backend = injector.get(XHRBackend); backend = injector.get(XHRBackend);

View File

@ -59,15 +59,15 @@ export function main() {
it('should allow using jsonpInjectables and httpInjectables in same injector', it('should allow using jsonpInjectables and httpInjectables in same injector',
inject([AsyncTestCompleter], (async) => { inject([AsyncTestCompleter], (async) => {
parentInjector = Injector.resolveAndCreate([ parentInjector = Injector.resolveAndCreate([
provide(XHRBackend, {asClass: MockBackend}), provide(XHRBackend, {useClass: MockBackend}),
provide(JSONPBackend, {asClass: MockBackend}) provide(JSONPBackend, {useClass: MockBackend})
]); ]);
childInjector = parentInjector.resolveAndCreateChild([ childInjector = parentInjector.resolveAndCreateChild([
HTTP_PROVIDERS, HTTP_PROVIDERS,
JSONP_PROVIDERS, JSONP_PROVIDERS,
provide(XHRBackend, {asClass: MockBackend}), provide(XHRBackend, {useClass: MockBackend}),
provide(JSONPBackend, {asClass: MockBackend}) provide(JSONPBackend, {useClass: MockBackend})
]); ]);
http = childInjector.get(Http); http = childInjector.get(Http);
@ -115,7 +115,7 @@ export function main() {
provide( provide(
Http, Http,
{ {
asFactory: function(backend: ConnectionBackend, defaultOptions: BaseRequestOptions) { useFactory: function(backend: ConnectionBackend, defaultOptions: BaseRequestOptions) {
return new Http(backend, defaultOptions); return new Http(backend, defaultOptions);
}, },
deps: [MockBackend, BaseRequestOptions] deps: [MockBackend, BaseRequestOptions]
@ -123,7 +123,7 @@ export function main() {
provide( provide(
Jsonp, Jsonp,
{ {
asFactory: function(backend: ConnectionBackend, defaultOptions: BaseRequestOptions) { useFactory: function(backend: ConnectionBackend, defaultOptions: BaseRequestOptions) {
return new Jsonp(backend, defaultOptions); return new Jsonp(backend, defaultOptions);
}, },
deps: [MockBackend, BaseRequestOptions] deps: [MockBackend, BaseRequestOptions]

View File

@ -109,18 +109,22 @@ var NG_API = [
'Binding', 'Binding',
'Binding.dependencies', 'Binding.dependencies',
'Binding.multi', 'Binding.multi',
'Binding.useExisting',
'Binding.useClass',
'Binding.useFactory',
'Binding.useValue',
'Binding.token',
'Binding.toAlias', 'Binding.toAlias',
'Binding.toClass', 'Binding.toClass',
'Binding.toFactory', 'Binding.toFactory',
'Binding.toValue', 'Binding.toValue',
'Binding.token',
'Provider', 'Provider',
'Provider.dependencies', 'Provider.dependencies',
'Provider.multi', 'Provider.multi',
'Provider.toAlias', 'Provider.useExisting',
'Provider.toClass', 'Provider.useClass',
'Provider.toFactory', 'Provider.useFactory',
'Provider.toValue', 'Provider.useValue',
'Provider.token', 'Provider.token',
'ProviderBuilder', 'ProviderBuilder',
'ProviderBuilder.toAlias()', 'ProviderBuilder.toAlias()',

View File

@ -64,10 +64,10 @@ export function main() {
beforeEachBindings(() => [ beforeEachBindings(() => [
RouteRegistry, RouteRegistry,
DirectiveResolver, DirectiveResolver,
provide(Location, {asClass: SpyLocation}), provide(Location, {useClass: SpyLocation}),
provide(Router, provide(Router,
{ {
asFactory: useFactory:
(registry, location) => { return new RootRouter(registry, location, MyComp); }, (registry, location) => { return new RootRouter(registry, location, MyComp); },
deps: [RouteRegistry, Location] deps: [RouteRegistry, Location]
}) })

View File

@ -48,10 +48,10 @@ export function main() {
beforeEachBindings(() => [ beforeEachBindings(() => [
RouteRegistry, RouteRegistry,
DirectiveResolver, DirectiveResolver,
provide(Location, {asClass: SpyLocation}), provide(Location, {useClass: SpyLocation}),
provide(Router, provide(Router,
{ {
asFactory: useFactory:
(registry, location) => { return new RootRouter(registry, location, MyComp); }, (registry, location) => { return new RootRouter(registry, location, MyComp); },
deps: [RouteRegistry, Location] deps: [RouteRegistry, Location]
}) })

View File

@ -38,7 +38,7 @@ import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
export function main() { export function main() {
describe('router injectables', () => { describe('router injectables', () => {
beforeEachBindings(() => { beforeEachBindings(() => {
return [ROUTER_PROVIDERS, provide(LocationStrategy, {asClass: MockLocationStrategy})]; return [ROUTER_PROVIDERS, provide(LocationStrategy, {useClass: MockLocationStrategy})];
}); });
// do not refactor out the `bootstrap` functionality. We still want to // do not refactor out the `bootstrap` functionality. We still want to
@ -52,9 +52,9 @@ export function main() {
bootstrap(AppCmp, bootstrap(AppCmp,
[ [
ROUTER_PROVIDERS, ROUTER_PROVIDERS,
provide(ROUTER_PRIMARY_COMPONENT, {asValue: AppCmp}), provide(ROUTER_PRIMARY_COMPONENT, {useValue: AppCmp}),
provide(LocationStrategy, {asClass: MockLocationStrategy}), provide(LocationStrategy, {useClass: MockLocationStrategy}),
provide(DOCUMENT, {asValue: fakeDoc}) provide(DOCUMENT, {useValue: fakeDoc})
]) ])
.then((applicationRef) => { .then((applicationRef) => {
var router = applicationRef.hostComponent.router; var router = applicationRef.hostComponent.router;
@ -69,7 +69,7 @@ export function main() {
describe('broken app', () => { describe('broken app', () => {
beforeEachBindings( beforeEachBindings(
() => { return [provide(ROUTER_PRIMARY_COMPONENT, {asValue: BrokenAppCmp})]; }); () => { return [provide(ROUTER_PRIMARY_COMPONENT, {useValue: BrokenAppCmp})]; });
it('should rethrow exceptions from component constructors', it('should rethrow exceptions from component constructors',
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => { inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
@ -86,7 +86,7 @@ export function main() {
describe('back button app', () => { describe('back button app', () => {
beforeEachBindings( beforeEachBindings(
() => { return [provide(ROUTER_PRIMARY_COMPONENT, {asValue: HierarchyAppCmp})]; }); () => { return [provide(ROUTER_PRIMARY_COMPONENT, {useValue: HierarchyAppCmp})]; });
it('should change the url without pushing a new history state for back navigations', it('should change the url without pushing a new history state for back navigations',
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => { inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
@ -138,7 +138,7 @@ export function main() {
describe('hierarchical app', () => { describe('hierarchical app', () => {
beforeEachBindings( beforeEachBindings(
() => { return [provide(ROUTER_PRIMARY_COMPONENT, {asValue: HierarchyAppCmp})]; }); () => { return [provide(ROUTER_PRIMARY_COMPONENT, {useValue: HierarchyAppCmp})]; });
it('should bootstrap an app with a hierarchy', it('should bootstrap an app with a hierarchy',
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => { inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
@ -158,7 +158,7 @@ export function main() {
})); }));
describe('custom app base ref', () => { describe('custom app base ref', () => {
beforeEachBindings(() => { return [provide(APP_BASE_HREF, {asValue: '/my/app'})]; }); beforeEachBindings(() => { return [provide(APP_BASE_HREF, {useValue: '/my/app'})]; });
it('should bootstrap', it('should bootstrap',
inject([AsyncTestCompleter, TestComponentBuilder], inject([AsyncTestCompleter, TestComponentBuilder],
(async, tcb: TestComponentBuilder) => { (async, tcb: TestComponentBuilder) => {
@ -182,7 +182,7 @@ export function main() {
describe('querystring params app', () => { describe('querystring params app', () => {
beforeEachBindings( beforeEachBindings(
() => { return [provide(ROUTER_PRIMARY_COMPONENT, {asValue: QueryStringAppCmp})]; }); () => { return [provide(ROUTER_PRIMARY_COMPONENT, {useValue: QueryStringAppCmp})]; });
it('should recognize and return querystring params with the injected RouteParams', it('should recognize and return querystring params with the injected RouteParams',
inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => { inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {

View File

@ -48,10 +48,10 @@ export function main() {
beforeEachBindings(() => [ beforeEachBindings(() => [
RouteRegistry, RouteRegistry,
DirectiveResolver, DirectiveResolver,
provide(Location, {asClass: SpyLocation}), provide(Location, {useClass: SpyLocation}),
provide(Router, provide(Router,
{ {
asFactory: useFactory:
(registry, location) => { return new RootRouter(registry, location, MyComp); }, (registry, location) => { return new RootRouter(registry, location, MyComp); },
deps: [RouteRegistry, Location] deps: [RouteRegistry, Location]
}) })

View File

@ -27,7 +27,7 @@ export function main() {
locationStrategy = new MockLocationStrategy(); locationStrategy = new MockLocationStrategy();
locationStrategy.internalBaseHref = baseHref; locationStrategy.internalBaseHref = baseHref;
let injector = Injector.resolveAndCreate( let injector = Injector.resolveAndCreate(
[Location, provide(LocationStrategy, {asValue: locationStrategy}), provider]); [Location, provide(LocationStrategy, {useValue: locationStrategy}), provider]);
return location = injector.get(Location); return location = injector.get(Location);
} }
@ -71,7 +71,7 @@ export function main() {
}); });
it('should use optional base href param', () => { it('should use optional base href param', () => {
let location = makeLocation('/', provide(APP_BASE_HREF, {asValue: '/my/custom/href'})); let location = makeLocation('/', provide(APP_BASE_HREF, {useValue: '/my/custom/href'}));
location.go('user/btford'); location.go('user/btford');
expect(locationStrategy.path()).toEqual('/my/custom/href/user/btford'); expect(locationStrategy.path()).toEqual('/my/custom/href/user/btford');
}); });

View File

@ -49,9 +49,9 @@ export function main() {
var exceptionHandler = new ExceptionHandler(logger, true); var exceptionHandler = new ExceptionHandler(logger, true);
testBindings = [ testBindings = [
ROUTER_PROVIDERS, ROUTER_PROVIDERS,
provide(LocationStrategy, {asClass: MockLocationStrategy}), provide(LocationStrategy, {useClass: MockLocationStrategy}),
provide(DOCUMENT, {asValue: fakeDoc}), provide(DOCUMENT, {useValue: fakeDoc}),
provide(ExceptionHandler, {asValue: exceptionHandler}) provide(ExceptionHandler, {useValue: exceptionHandler})
]; ];
}); });

View File

@ -41,8 +41,8 @@ export function main() {
var tcb: TestComponentBuilder; var tcb: TestComponentBuilder;
beforeEachBindings(() => [ beforeEachBindings(() => [
provide(Location, {asValue: makeDummyLocation()}), provide(Location, {useValue: makeDummyLocation()}),
provide(Router, {asValue: makeDummyRouter()}) provide(Router, {useValue: makeDummyRouter()})
]); ]);
beforeEach(inject([TestComponentBuilder], (tcBuilder) => { tcb = tcBuilder; })); beforeEach(inject([TestComponentBuilder], (tcBuilder) => { tcb = tcBuilder; }));

View File

@ -33,10 +33,10 @@ export function main() {
beforeEachBindings(() => [ beforeEachBindings(() => [
RouteRegistry, RouteRegistry,
DirectiveResolver, DirectiveResolver,
provide(Location, {asClass: SpyLocation}), provide(Location, {useClass: SpyLocation}),
provide(Router, provide(Router,
{ {
asFactory: useFactory:
(registry, location) => { return new RootRouter(registry, location, AppCmp); }, (registry, location) => { return new RootRouter(registry, location, AppCmp); },
deps: [RouteRegistry, Location] deps: [RouteRegistry, Location]
}) })

View File

@ -178,7 +178,7 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideProviders(TestBindingsComp, tcb.overrideProviders(TestBindingsComp,
[provide(FancyService, {asClass: MockFancyService})]) [provide(FancyService, {useClass: MockFancyService})])
.createAsync(TestBindingsComp) .createAsync(TestBindingsComp)
.then((rootTestComponent) => { .then((rootTestComponent) => {
rootTestComponent.detectChanges(); rootTestComponent.detectChanges();
@ -193,7 +193,7 @@ export function main() {
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideViewProviders(TestViewBindingsComp, tcb.overrideViewProviders(TestViewBindingsComp,
[provide(FancyService, {asClass: MockFancyService})]) [provide(FancyService, {useClass: MockFancyService})])
.createAsync(TestViewBindingsComp) .createAsync(TestViewBindingsComp)
.then((rootTestComponent) => { .then((rootTestComponent) => {
rootTestComponent.detectChanges(); rootTestComponent.detectChanges();

View File

@ -7,7 +7,7 @@ export class SpyComponentRef extends SpyObject {
injector; injector;
constructor() { constructor() {
super(); super();
this.injector = Injector.resolveAndCreate([provide(LifeCycle, {asValue: {tick: () => {}}})]); this.injector = Injector.resolveAndCreate([provide(LifeCycle, {useValue: {tick: () => {}}})]);
} }
} }

View File

@ -33,7 +33,7 @@ export function main() {
const ID = "methodId"; const ID = "methodId";
beforeEachBindings(() => [ beforeEachBindings(() => [
provide(ON_WEB_WORKER, {asValue: true}), provide(ON_WEB_WORKER, {useValue: true}),
RenderProtoViewRefStore, RenderProtoViewRefStore,
RenderViewWithFragmentsStore RenderViewWithFragmentsStore
]); ]);

View File

@ -27,7 +27,7 @@ import {EVENT_CHANNEL} from 'angular2/src/web_workers/shared/messaging_api';
export function main() { export function main() {
describe("EventDispatcher", () => { describe("EventDispatcher", () => {
beforeEachBindings(() => [ beforeEachBindings(() => [
provide(ON_WEB_WORKER, {asValue: true}), provide(ON_WEB_WORKER, {useValue: true}),
RenderProtoViewRefStore, RenderProtoViewRefStore,
RenderViewWithFragmentsStore RenderViewWithFragmentsStore
]); ]);

View File

@ -104,21 +104,21 @@ export function main() {
var uiRenderProtoViewStore = new RenderProtoViewRefStore(false); var uiRenderProtoViewStore = new RenderProtoViewRefStore(false);
uiRenderViewStore = new RenderViewWithFragmentsStore(false); uiRenderViewStore = new RenderViewWithFragmentsStore(false);
uiInjector = createTestInjector([ uiInjector = createTestInjector([
provide(RenderProtoViewRefStore, {asValue: uiRenderProtoViewStore}), provide(RenderProtoViewRefStore, {useValue: uiRenderProtoViewStore}),
provide(RenderViewWithFragmentsStore, {asValue: uiRenderViewStore}), provide(RenderViewWithFragmentsStore, {useValue: uiRenderViewStore}),
provide(DomRenderer, {asClass: DomRenderer_}), provide(DomRenderer, {useClass: DomRenderer_}),
provide(Renderer, {asAlias: DomRenderer}) provide(Renderer, {useExisting: DomRenderer})
]); ]);
var uiSerializer = uiInjector.get(Serializer); var uiSerializer = uiInjector.get(Serializer);
var domRenderer = uiInjector.get(DomRenderer); var domRenderer = uiInjector.get(DomRenderer);
var workerRenderProtoViewStore = new RenderProtoViewRefStore(true); var workerRenderProtoViewStore = new RenderProtoViewRefStore(true);
var workerRenderViewStore = new RenderViewWithFragmentsStore(true); var workerRenderViewStore = new RenderViewWithFragmentsStore(true);
return [ return [
provide(RenderProtoViewRefStore, {asValue: workerRenderProtoViewStore}), provide(RenderProtoViewRefStore, {useValue: workerRenderProtoViewStore}),
provide(RenderViewWithFragmentsStore, {asValue: workerRenderViewStore}), provide(RenderViewWithFragmentsStore, {useValue: workerRenderViewStore}),
provide(Renderer, provide(Renderer,
{ {
asFactory: (workerSerializer) => { useFactory: (workerSerializer) => {
return createWorkerRenderer(workerSerializer, uiSerializer, domRenderer, return createWorkerRenderer(workerSerializer, uiSerializer, domRenderer,
uiRenderProtoViewStore, uiRenderViewStore, uiRenderProtoViewStore, uiRenderViewStore,
workerRenderProtoViewStore, workerRenderViewStore); workerRenderProtoViewStore, workerRenderViewStore);

View File

@ -55,7 +55,7 @@ export class MdDialog {
// Create the dialogRef here so that it can be injected into the content component. // Create the dialogRef here so that it can be injected into the content component.
var dialogRef = new MdDialogRef(); var dialogRef = new MdDialogRef();
var bindings = Injector.resolve([provide(MdDialogRef, {asValue: dialogRef})]); var bindings = Injector.resolve([provide(MdDialogRef, {useValue: dialogRef})]);
var backdropRefPromise = this._openBackdrop(elementRef, bindings); var backdropRefPromise = this._openBackdrop(elementRef, bindings);

View File

@ -37,7 +37,7 @@ export function main() {
// Need to use the real XHR implementation (instead of the mock) so we can actually request // Need to use the real XHR implementation (instead of the mock) so we can actually request
// the template files, since Angular 2 doesn't have anything like $templateCache. This should // the template files, since Angular 2 doesn't have anything like $templateCache. This should
// eventually be replaced with a preprocessor that inlines templates. // eventually be replaced with a preprocessor that inlines templates.
provide(XHR, {asClass: XHRImpl}) provide(XHR, {useClass: XHRImpl})
]); ]);
beforeEach(inject([TestComponentBuilder], (tcb) => { builder = tcb; })); beforeEach(inject([TestComponentBuilder], (tcb) => { builder = tcb; }));

View File

@ -28,7 +28,7 @@ function _createBindings(): Provider[] {
return [ return [
provide(ViewResolver, provide(ViewResolver,
{ {
asFactory: () => new MultiplyViewResolver( useFactory: () => new MultiplyViewResolver(
multiplyTemplatesBy, multiplyTemplatesBy,
[BenchmarkComponentNoBindings, BenchmarkComponentWithBindings]), [BenchmarkComponentNoBindings, BenchmarkComponentWithBindings]),
deps: [] deps: []
@ -36,7 +36,7 @@ function _createBindings(): Provider[] {
// Use DynamicChangeDetector as that is the only one that Dart supports as well // Use DynamicChangeDetector as that is the only one that Dart supports as well
// so that we can compare the numbers between JS and Dart // so that we can compare the numbers between JS and Dart
provide(ChangeDetectorGenConfig, provide(ChangeDetectorGenConfig,
{asValue: new ChangeDetectorGenConfig(false, false, false, false)}) {useValue: new ChangeDetectorGenConfig(false, false, false, false)})
]; ];
} }

View File

@ -27,7 +27,7 @@ export function main() {
.resolveAndCreateChild([]) .resolveAndCreateChild([])
.resolveAndCreateChild([]); .resolveAndCreateChild([]);
var variousProviders = [A, provide(B, {asClass: C}), [D, [E]], provide(F, {asValue: 6})]; var variousProviders = [A, provide(B, {useClass: C}), [D, [E]], provide(F, {useValue: 6})];
var variousProvidersResolved = Injector.resolve(variousProviders); var variousProvidersResolved = Injector.resolve(variousProviders);

View File

@ -35,11 +35,10 @@ export const LARGETABLE_COLS = 'LargetableComponent.cols';
function _createBindings() { function _createBindings() {
var viewCacheCapacity = getStringParameter('viewcache') == 'true' ? 10000 : 1; var viewCacheCapacity = getStringParameter('viewcache') == 'true' ? 10000 : 1;
return [ return [
bind(BENCHMARK_TYPE) provide(BENCHMARK_TYPE, {useValue: getStringParameter('benchmarkType')}),
.toValue(getStringParameter('benchmarkType')), provide(LARGETABLE_ROWS, {useValue: getIntParameter('rows')}),
provide(LARGETABLE_ROWS, {asValue: getIntParameter('rows')}), provide(LARGETABLE_COLS, {useValue: getIntParameter('columns')}),
provide(LARGETABLE_COLS, {asValue: getIntParameter('columns')}), provide(APP_VIEW_POOL_CAPACITY, {useValue: viewCacheCapacity})
provide(APP_VIEW_POOL_CAPACITY, {asValue: viewCacheCapacity})
]; ];
} }

View File

@ -10,5 +10,5 @@ export function main() {
} }
function createBindings(): any[] { function createBindings(): any[] {
return [provide(APP_VIEW_POOL_CAPACITY, {asValue: 100000})]; return [provide(APP_VIEW_POOL_CAPACITY, {useValue: 100000})];
} }

View File

@ -28,7 +28,7 @@ import {APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/linker/view_pool';
function createBindings(): Provider[] { function createBindings(): Provider[] {
var viewCacheCapacity = getStringParameter('viewcache') == 'true' ? 10000 : 0; var viewCacheCapacity = getStringParameter('viewcache') == 'true' ? 10000 : 0;
return [provide(APP_VIEW_POOL_CAPACITY, {asValue: viewCacheCapacity})]; return [provide(APP_VIEW_POOL_CAPACITY, {useValue: viewCacheCapacity})];
} }
function setupReflector() { function setupReflector() {

View File

@ -27,7 +27,7 @@ import {APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/linker/view_pool';
function createProviders(): Provider[] { function createProviders(): Provider[] {
var viewCacheCapacity = getStringParameter('viewcache') == 'true' ? 10000 : 1; var viewCacheCapacity = getStringParameter('viewcache') == 'true' ? 10000 : 1;
return [provide(APP_VIEW_POOL_CAPACITY, {asValue: viewCacheCapacity})]; return [provide(APP_VIEW_POOL_CAPACITY, {useValue: viewCacheCapacity})];
} }
var BASELINE_TREE_TEMPLATE; var BASELINE_TREE_TEMPLATE;

View File

@ -45,10 +45,10 @@ var _CAPTURE_FRAMES = new OpaqueToken('Options.frameCapture');
var _DEFAULT_PROVIDERS = [ var _DEFAULT_PROVIDERS = [
bind(_DEFAULT_DESCRIPTION) bind(_DEFAULT_DESCRIPTION)
.toValue({}), .toValue({}),
provide(_SAMPLE_DESCRIPTION, {asValue: {}}), provide(_SAMPLE_DESCRIPTION, {useValue: {}}),
provide(_FORCE_GC, {asValue: false}), provide(_FORCE_GC, {useValue: false}),
provide(_PREPARE, {asValue: false}), provide(_PREPARE, {useValue: false}),
provide(_MICRO_METRICS, {asValue: {}}), provide(_MICRO_METRICS, {useValue: {}}),
provide(_NOW, {asValue: () => DateWrapper.now()}), provide(_NOW, {useValue: () => DateWrapper.now()}),
provide(_CAPTURE_FRAMES, {asValue: false}) provide(_CAPTURE_FRAMES, {useValue: false})
]; ];

View File

@ -1,11 +1,11 @@
import {bind, provide, Binding, Injector, OpaqueToken} from 'angular2/src/core/di'; import {bind, provide, Binding, Provider, Injector, OpaqueToken} from 'angular2/src/core/di';
import {StringMapWrapper} from 'angular2/src/core/facade/collection'; import {StringMapWrapper} from 'angular2/src/core/facade/collection';
import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async'; import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async';
import {Metric} from '../metric'; import {Metric} from '../metric';
export class MultiMetric extends Metric { export class MultiMetric extends Metric {
static createBindings(childTokens: any[]): Binding[] { static createBindings(childTokens: any[]): Provider[] {
return [ return [
bind(_CHILDREN) bind(_CHILDREN)
.toFactory((injector: Injector) => childTokens.map(token => injector.get(token)), .toFactory((injector: Injector) => childTokens.map(token => injector.get(token)),

View File

@ -343,5 +343,5 @@ var _PROVIDERS = [
Options.FORCE_GC, Options.FORCE_GC,
Options.CAPTURE_FRAMES Options.CAPTURE_FRAMES
]), ]),
provide(_SET_TIMEOUT, {asValue: (fn, millis) => TimerWrapper.setTimeout(fn, millis)}) provide(_SET_TIMEOUT, {useValue: (fn, millis) => TimerWrapper.setTimeout(fn, millis)})
]; ];

View File

@ -98,6 +98,6 @@ var _PROVIDERS = [
.toFactory((columnWidth, sampleDescription, print) => .toFactory((columnWidth, sampleDescription, print) =>
new ConsoleReporter(columnWidth, sampleDescription, print), new ConsoleReporter(columnWidth, sampleDescription, print),
[_COLUMN_WIDTH, SampleDescription, _PRINT]), [_COLUMN_WIDTH, SampleDescription, _PRINT]),
provide(_COLUMN_WIDTH, {asValue: 18}), provide(_COLUMN_WIDTH, {useValue: 18}),
provide(_PRINT, {asValue: print}) provide(_PRINT, {useValue: print})
]; ];

View File

@ -52,5 +52,5 @@ var _PROVIDERS = [
.toFactory((sampleDescription, path, writeFile, now) => .toFactory((sampleDescription, path, writeFile, now) =>
new JsonFileReporter(sampleDescription, path, writeFile, now), new JsonFileReporter(sampleDescription, path, writeFile, now),
[SampleDescription, _PATH, Options.WRITE_FILE, Options.NOW]), [SampleDescription, _PATH, Options.WRITE_FILE, Options.NOW]),
provide(_PATH, {asValue: '.'}) provide(_PATH, {useValue: '.'})
]; ];

View File

@ -68,7 +68,7 @@ export class Runner {
sampleBindings, sampleBindings,
bind(Options.CAPABILITIES).toValue(capabilities), bind(Options.CAPABILITIES).toValue(capabilities),
bind(Options.USER_AGENT).toValue(userAgent), bind(Options.USER_AGENT).toValue(userAgent),
provide(WebDriverAdapter, {asValue: adapter}) provide(WebDriverAdapter, {useValue: adapter})
]); ]);
var sampler = injector.get(Sampler); var sampler = injector.get(Sampler);

View File

@ -57,6 +57,6 @@ var _PROVIDERS = [
bind(RegressionSlopeValidator) bind(RegressionSlopeValidator)
.toFactory((sampleSize, metric) => new RegressionSlopeValidator(sampleSize, metric), .toFactory((sampleSize, metric) => new RegressionSlopeValidator(sampleSize, metric),
[_SAMPLE_SIZE, _METRIC]), [_SAMPLE_SIZE, _METRIC]),
provide(_SAMPLE_SIZE, {asValue: 10}), provide(_SAMPLE_SIZE, {useValue: 10}),
provide(_METRIC, {asValue: 'scriptTime'}) provide(_METRIC, {useValue: 'scriptTime'})
]; ];

View File

@ -36,5 +36,5 @@ var _SAMPLE_SIZE = new OpaqueToken('SizeValidator.sampleSize');
var _PROVIDERS = [ var _PROVIDERS = [
bind(SizeValidator) bind(SizeValidator)
.toFactory((size) => new SizeValidator(size), [_SAMPLE_SIZE]), .toFactory((size) => new SizeValidator(size), [_SAMPLE_SIZE]),
provide(_SAMPLE_SIZE, {asValue: 10}) provide(_SAMPLE_SIZE, {useValue: 10})
]; ];

View File

@ -19,7 +19,7 @@ import {Metric, MultiMetric, bind, provide, Injector} from 'benchpress/common';
export function main() { export function main() {
function createMetric(ids: any[]) { function createMetric(ids: any[]) {
var m = Injector.resolveAndCreate([ var m = Injector.resolveAndCreate([
ids.map(id => provide(id, {asValue: new MockMetric(id)})), ids.map(id => provide(id, {useValue: new MockMetric(id)})),
MultiMetric.createBindings(ids) MultiMetric.createBindings(ids)
]) ])
.get(MultiMetric); .get(MultiMetric);

View File

@ -30,7 +30,7 @@ export function main() {
var bindings = [ var bindings = [
ConsoleReporter.BINDINGS, ConsoleReporter.BINDINGS,
provide(SampleDescription, provide(SampleDescription,
{asValue: new SampleDescription(sampleId, descriptions, metrics)}), {useValue: new SampleDescription(sampleId, descriptions, metrics)}),
bind(ConsoleReporter.PRINT).toValue((line) => log.push(line)) bind(ConsoleReporter.PRINT).toValue((line) => log.push(line))
]; ];
if (isPresent(columnWidth)) { if (isPresent(columnWidth)) {

View File

@ -34,7 +34,7 @@ export function main() {
var bindings = [ var bindings = [
JsonFileReporter.BINDINGS, JsonFileReporter.BINDINGS,
provide(SampleDescription, provide(SampleDescription,
{asValue: new SampleDescription(sampleId, descriptions, metrics)}), {useValue: new SampleDescription(sampleId, descriptions, metrics)}),
bind(JsonFileReporter.PATH).toValue(path), bind(JsonFileReporter.PATH).toValue(path),
bind(Options.NOW).toValue(() => DateWrapper.fromMillis(1234)), bind(Options.NOW).toValue(() => DateWrapper.fromMillis(1234)),
bind(Options.WRITE_FILE) bind(Options.WRITE_FILE)

View File

@ -19,7 +19,7 @@ import {Reporter, MultiReporter, bind, provide, Injector, MeasureValues} from 'b
export function main() { export function main() {
function createReporters(ids: any[]) { function createReporters(ids: any[]) {
var r = Injector.resolveAndCreate([ var r = Injector.resolveAndCreate([
ids.map(id => provide(id, {asValue: new MockReporter(id)})), ids.map(id => provide(id, {useValue: new MockReporter(id)})),
MultiReporter.createBindings(ids) MultiReporter.createBindings(ids)
]) ])
.get(MultiReporter); .get(MultiReporter);

View File

@ -54,11 +54,11 @@ export function main() {
var bindings = [ var bindings = [
Options.DEFAULT_PROVIDERS, Options.DEFAULT_PROVIDERS,
Sampler.BINDINGS, Sampler.BINDINGS,
provide(Metric, {asValue: metric}), provide(Metric, {useValue: metric}),
provide(Reporter, {asValue: reporter}), provide(Reporter, {useValue: reporter}),
provide(WebDriverAdapter, {asValue: driver}), provide(WebDriverAdapter, {useValue: driver}),
bind(Options.EXECUTE).toValue(execute), bind(Options.EXECUTE).toValue(execute),
provide(Validator, {asValue: validator}), provide(Validator, {useValue: validator}),
bind(Options.NOW).toValue(() => DateWrapper.fromMillis(time++)) bind(Options.NOW).toValue(() => DateWrapper.fromMillis(time++))
]; ];
if (isPresent(prepare)) { if (isPresent(prepare)) {

View File

@ -20,7 +20,7 @@ export function main() {
function createExtension(ids: any[], caps) { function createExtension(ids: any[], caps) {
return PromiseWrapper.wrap(() => { return PromiseWrapper.wrap(() => {
return Injector.resolveAndCreate([ return Injector.resolveAndCreate([
ids.map(id => provide(id, {asValue: new MockExtension(id)})), ids.map(id => provide(id, {useValue: new MockExtension(id)})),
bind(Options.CAPABILITIES).toValue(caps), bind(Options.CAPABILITIES).toValue(caps),
WebDriverExtension.bindTo(ids) WebDriverExtension.bindTo(ids)
]) ])

View File

@ -40,7 +40,7 @@ export function main() {
extension = extension =
Injector.resolveAndCreate([ Injector.resolveAndCreate([
IOsDriverExtension.BINDINGS, IOsDriverExtension.BINDINGS,
provide(WebDriverAdapter, {asValue: new MockDriverAdapter(log, perfRecords)}) provide(WebDriverAdapter, {useValue: new MockDriverAdapter(log, perfRecords)})
]) ])
.get(IOsDriverExtension); .get(IOsDriverExtension);
return extension; return extension;

View File

@ -40,5 +40,5 @@ class DemoApp {
export function main() { export function main() {
commonDemoSetup(); commonDemoSetup();
bootstrap(DemoApp, [provide(UrlResolver, {asValue: new DemoUrlResolver()})]); bootstrap(DemoApp, [provide(UrlResolver, {useValue: new DemoUrlResolver()})]);
} }

View File

@ -34,5 +34,5 @@ class DemoApp {
export function main() { export function main() {
commonDemoSetup(); commonDemoSetup();
bootstrap(DemoApp, [provide(UrlResolver, {asValue: new DemoUrlResolver()})]); bootstrap(DemoApp, [provide(UrlResolver, {useValue: new DemoUrlResolver()})]);
} }

Some files were not shown because too many files have changed in this diff Show More