UNPKG

static-injector

Version:

Angular 依赖注入独立版本;Angular dependency injection standalone version

61 lines (60 loc) 2.51 kB
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { Type } from '../interface/type'; import { ClassProvider, ConstructorProvider, EnvironmentProviders, ExistingProvider, FactoryProvider, ModuleWithProviders, Provider, StaticClassProvider, TypeProvider, ValueProvider } from './interface/provider'; /** * Wrap an array of `Provider`s into `EnvironmentProviders`, preventing them from being accidentally * referenced in `@Component` in a component injector. * * @publicApi */ export declare function makeEnvironmentProviders(providers: (Provider | EnvironmentProviders)[]): EnvironmentProviders; /** * @description * This function is used to provide initialization functions that will be executed upon construction * of an environment injector. * * Note that the provided initializer is run in the injection context. * * Previously, this was achieved using the `ENVIRONMENT_INITIALIZER` token which is now deprecated. * * @see {@link ENVIRONMENT_INITIALIZER} * * @usageNotes * The following example illustrates how to configure an initialization function using * `provideEnvironmentInitializer()` * ```ts * createEnvironmentInjector( * [ * provideEnvironmentInitializer(() => { * console.log('environment initialized'); * }), * ], * parentInjector * ); * ``` * * @publicApi */ export declare function provideEnvironmentInitializer(initializerFn: () => void): EnvironmentProviders; /** * A source of providers for the `importProvidersFrom` function. * * @publicApi */ export type ImportProvidersSource = Type<unknown> | ModuleWithProviders<unknown> | Array<ImportProvidersSource>; /** * Internal type for a single provider in a deep provider array. */ export type SingleProvider = TypeProvider | ValueProvider | ClassProvider | ConstructorProvider | ExistingProvider | FactoryProvider | StaticClassProvider; export declare const USE_VALUE: string; export declare function isValueProvider(value: SingleProvider): value is ValueProvider; export declare function isExistingProvider(value: SingleProvider): value is ExistingProvider; export declare function isFactoryProvider(value: SingleProvider): value is FactoryProvider; export declare function isTypeProvider(value: SingleProvider): value is TypeProvider; export declare function isClassProvider(value: SingleProvider): value is ClassProvider;