UNPKG

1.31 kBTypeScriptView Raw
1import { ObjectType } from "./ObjectType";
2import { Token } from "../Token";
3/**
4 * Service metadata is used to initialize service and store its state.
5 */
6export interface ServiceMetadata<T, K extends keyof T> {
7 /**
8 * Class type of the registering service.
9 * Can be omitted only if instance is set.
10 * If id is not set then it serves as service id.
11 */
12 type?: Function;
13 /**
14 * Indicates if this service must be global and same instance must be used across all containers.
15 */
16 global?: boolean;
17 /**
18 * Indicates if instance of this class must be created on each its request.
19 * Global option is ignored when this option is used.
20 */
21 transient?: boolean;
22 /**
23 * Allows to setup multiple instances the different classes under a single service id string or token.
24 */
25 multiple?: boolean;
26 /**
27 * Service unique identifier.
28 */
29 id?: Token<any> | string | Function;
30 /**
31 * Factory function used to initialize this service.
32 * Can be regular function ("createCar" for example),
33 * or other service which produces this instance ([CarFactory, "createCar"] for example).
34 */
35 factory?: [ObjectType<T>, K] | ((...params: any[]) => any);
36 /**
37 * Instance of the target class.
38 */
39 value?: any;
40}
41
\No newline at end of file