UNPKG

3.38 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google Inc. All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { Self, SkipSelf } from './metadata';
9import { Provider } from './provider';
10import { ReflectiveKey } from './reflective_key';
11/**
12 * `Dependency` is used by the framework to extend DI.
13 * This is internal to Angular and should not be used directly.
14 */
15export declare class ReflectiveDependency {
16 key: ReflectiveKey;
17 optional: boolean;
18 visibility: Self | SkipSelf | null;
19 constructor(key: ReflectiveKey, optional: boolean, visibility: Self | SkipSelf | null);
20 static fromKey(key: ReflectiveKey): ReflectiveDependency;
21}
22/**
23 * An internal resolved representation of a {@link Provider} used by the {@link Injector}.
24 *
25 * It is usually created automatically by `Injector.resolveAndCreate`.
26 *
27 * It can be created manually, as follows:
28 *
29 * ### Example ([live demo](http://plnkr.co/edit/RfEnhh8kUEI0G3qsnIeT?p%3Dpreview&p=preview))
30 *
31 * ```typescript
32 * var resolvedProviders = Injector.resolve([{ provide: 'message', useValue: 'Hello' }]);
33 * var injector = Injector.fromResolvedProviders(resolvedProviders);
34 *
35 * expect(injector.get('message')).toEqual('Hello');
36 * ```
37 *
38 * @experimental
39 */
40export interface ResolvedReflectiveProvider {
41 /**
42 * A key, usually a `Type<any>`.
43 */
44 key: ReflectiveKey;
45 /**
46 * Factory function which can return an instance of an object represented by a key.
47 */
48 resolvedFactories: ResolvedReflectiveFactory[];
49 /**
50 * Indicates if the provider is a multi-provider or a regular provider.
51 */
52 multiProvider: boolean;
53}
54export declare class ResolvedReflectiveProvider_ implements ResolvedReflectiveProvider {
55 key: ReflectiveKey;
56 resolvedFactories: ResolvedReflectiveFactory[];
57 multiProvider: boolean;
58 constructor(key: ReflectiveKey, resolvedFactories: ResolvedReflectiveFactory[], multiProvider: boolean);
59 get resolvedFactory(): ResolvedReflectiveFactory;
60}
61/**
62 * An internal resolved representation of a factory function created by resolving {@link
63 * Provider}.
64 * @experimental
65 */
66export declare class ResolvedReflectiveFactory {
67 /**
68 * Factory function which can return an instance of an object represented by a key.
69 */
70 factory: Function;
71 /**
72 * Arguments (dependencies) to the `factory` function.
73 */
74 dependencies: ReflectiveDependency[];
75 constructor(
76 /**
77 * Factory function which can return an instance of an object represented by a key.
78 */
79 factory: Function,
80 /**
81 * Arguments (dependencies) to the `factory` function.
82 */
83 dependencies: ReflectiveDependency[]);
84}
85/**
86 * Resolve a list of Providers.
87 */
88export declare function resolveReflectiveProviders(providers: Provider[]): ResolvedReflectiveProvider[];
89/**
90 * Merges a list of ResolvedProviders into a list where
91 * each key is contained exactly once and multi providers
92 * have been merged.
93 */
94export declare function mergeResolvedReflectiveProviders(providers: ResolvedReflectiveProvider[], normalizedProvidersMap: Map<number, ResolvedReflectiveProvider>): Map<number, ResolvedReflectiveProvider>;
95export declare function constructDependencies(typeOrFunc: any, dependencies?: any[]): ReflectiveDependency[];