UNPKG

6.35 kBSource Map (JSON)View Raw
1{"version":3,"file":"provider.js","sourceRoot":"","sources":["../lib/provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport { Type } from './facade/type';\n\n/**\n * @whatItDoes Configures the {@link Injector} to return an instance of `Type` when `Type' is used\n * as token.\n * @howToUse\n * ```\n * @Injectable()\n * class MyService {}\n *\n * const provider: TypeProvider = MyService;\n * ```\n *\n * @description\n *\n * Create an instance by invoking the `new` operator and supplying additional arguments.\n * This form is a short form of `TypeProvider`;\n *\n * For more details, see the {@linkDocs guide/dependency-injection \"Dependency Injection Guide\"}.\n *\n * ### Example\n *\n * {@example core/di/ts/provider_spec.ts region='TypeProvider'}\n *\n * @stable\n */\nexport interface TypeProvider extends Type<any> {}\n\n/**\n * @whatItDoes Configures the {@link Injector} to return a value for a token.\n * @howToUse\n * ```\n * const provider: ValueProvider = {provide: 'someToken', useValue: 'someValue'};\n * ```\n *\n * @description\n * For more details, see the {@linkDocs guide/dependency-injection \"Dependency Injection Guide\"}.\n *\n * ### Example\n *\n * {@example core/di/ts/provider_spec.ts region='ValueProvider'}\n *\n * @stable\n */\nexport interface ValueProvider {\n /**\n * An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).\n */\n provide: any;\n\n /**\n * The value to inject.\n */\n useValue: any;\n\n /**\n * If true, then injector returns an array of instances. This is useful to allow multiple\n * providers spread across many files to provide configuration information to a common token.\n *\n * ### Example\n *\n * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}\n */\n multi?: boolean;\n}\n\n/**\n * @whatItDoes Configures the {@link Injector} to return an instance of `useClass` for a token.\n * @howToUse\n * ```\n * @Injectable()\n * class MyService {}\n *\n * const provider: ClassProvider = {provide: 'someToken', useClass: MyService};\n * ```\n *\n * @description\n * For more details, see the {@linkDocs guide/dependency-injection \"Dependency Injection Guide\"}.\n *\n * ### Example\n *\n * {@example core/di/ts/provider_spec.ts region='ClassProvider'}\n *\n * Note that following two providers are not equal:\n * {@example core/di/ts/provider_spec.ts region='ClassProviderDifference'}\n *\n * @stable\n */\nexport interface ClassProvider {\n /**\n * An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).\n */\n provide: any;\n\n /**\n * Class to instantiate for the `token`.\n */\n useClass: Type<any>;\n\n /**\n * If true, then injector returns an array of instances. This is useful to allow multiple\n * providers spread across many files to provide configuration information to a common token.\n *\n * ### Example\n *\n * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}\n */\n multi?: boolean;\n}\n\n/**\n * @whatItDoes Configures the {@link Injector} to return a value of another `useExisting` token.\n * @howToUse\n * ```\n * const provider: ExistingProvider = {provide: 'someToken', useExisting: 'someOtherToken'};\n * ```\n *\n * @description\n * For more details, see the {@linkDocs guide/dependency-injection \"Dependency Injection Guide\"}.\n *\n * ### Example\n *\n * {@example core/di/ts/provider_spec.ts region='ExistingProvider'}\n *\n * @stable\n */\nexport interface ExistingProvider {\n /**\n * An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).\n */\n provide: any;\n\n /**\n * Existing `token` to return. (equivalent to `injector.get(useExisting)`)\n */\n useExisting: any;\n\n /**\n * If true, then injector returns an array of instances. This is useful to allow multiple\n * providers spread across many files to provide configuration information to a common token.\n *\n * ### Example\n *\n * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}\n */\n multi?: boolean;\n}\n\n/**\n * @whatItDoes Configures the {@link Injector} to return a value by invoking a `useFactory`\n * function.\n * @howToUse\n * ```\n * function serviceFactory() { ... }\n *\n * const provider: FactoryProvider = {provide: 'someToken', useFactory: serviceFactory, deps: []};\n * ```\n *\n * @description\n * For more details, see the {@linkDocs guide/dependency-injection \"Dependency Injection Guide\"}.\n *\n * ### Example\n *\n * {@example core/di/ts/provider_spec.ts region='FactoryProvider'}\n *\n * Dependencies can also be marked as optional:\n * {@example core/di/ts/provider_spec.ts region='FactoryProviderOptionalDeps'}\n *\n * @stable\n */\nexport interface FactoryProvider {\n /**\n * An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).\n */\n provide: any;\n\n /**\n * A function to invoke to create a value for this `token`. The function is invoked with\n * resolved values of `token`s in the `deps` field.\n */\n useFactory: Function;\n\n /**\n * A list of `token`s which need to be resolved by the injector. The list of values is then\n * used as arguments to the `useFactory` function.\n */\n deps?: any[];\n\n /**\n * If true, then injector returns an array of instances. This is useful to allow multiple\n * providers spread across many files to provide configuration information to a common token.\n *\n * ### Example\n *\n * {@example core/di/ts/provider_spec.ts region='MultiProviderAspect'}\n */\n multi?: boolean;\n}\n\n/**\n * @whatItDoes Describes how the {@link Injector} should be configured.\n * @howToUse\n * See {@link TypeProvider}, {@link ValueProvider}, {@link ClassProvider}, {@link ExistingProvider},\n * {@link FactoryProvider}.\n *\n * @description\n * For more details, see the {@linkDocs guide/dependency-injection \"Dependency Injection Guide\"}.\n *\n * @stable\n */\nexport type Provider = TypeProvider | ValueProvider | ClassProvider | ExistingProvider | FactoryProvider | any[];\n"]}
\No newline at end of file