UNPKG

1.97 kBTypeScriptView Raw
1import { Constructor } from '../Contracts';
2/**
3 * Registrar is used to register and boot the providers
4 */
5export declare class Registrar {
6 private providerConstructorParams;
7 private basePath?;
8 /**
9 * The first level of provider paths provided to the registrar
10 */
11 private providersPaths;
12 /**
13 * An array of loaded providers. Their can be more providers than the
14 * `_providersPaths` array, since each provider can provide it's
15 * own sub providers
16 */
17 private providers;
18 /**
19 * Method to instantiate provider instances. One can also defined
20 * a custom instantiater function
21 */
22 private providersInstantiater;
23 /**
24 * Whether or not the providers can be collected
25 */
26 private collected;
27 constructor(providerConstructorParams: any[], basePath?: string | undefined);
28 /**
29 * Load the provider by requiring the file from the disk
30 * and instantiate it. If ioc container is using ES6
31 * imports, then default exports are handled
32 * automatically.
33 */
34 private loadProvider;
35 /**
36 * Loop's over an array of provider paths and pushes them to the
37 * `providers` collection. This collection is later used to
38 * register and boot providers
39 */
40 private collect;
41 /**
42 * Register an array of provider paths
43 */
44 useProviders(providersPaths: string[], callback?: <T extends Constructor<any>>(provider: T) => InstanceType<T>): this;
45 /**
46 * Register all the providers by instantiating them and
47 * calling the `register` method.
48 *
49 * The provider instance will be returned, which can be used
50 * to boot them as well.
51 */
52 register(): Promise<any[]>;
53 /**
54 * Boot all the providers by calling the `boot` method.
55 * Boot methods are called in series.
56 */
57 boot(): Promise<void>;
58 /**
59 * Register an boot providers together.
60 */
61 registerAndBoot(): Promise<any[]>;
62}