UNPKG

1.81 kBTypeScriptView Raw
1import { FactoryDefinition } from './factory';
2export interface RegistrationOptions {
3 singleton?: boolean;
4 instantiate?: boolean;
5}
6export interface Injection {
7 property: string;
8 source: string;
9}
10export interface RegistryWriter {
11 register(specifier: string, factory: any, options?: RegistrationOptions): void;
12 unregister(specifier: string): void;
13 registerOption(specifier: string, option: string, value: any): void;
14 unregisterOption(specifier: string, option: string): void;
15 registerInjection(specifier: string, property: string, source: string): void;
16}
17export interface RegistryReader {
18 registration(specifier: string): any;
19 registeredOption(specifier: string, option: string): any;
20 registeredOptions(specifier: string): any;
21 registeredInjections(specifier: string): Injection[];
22}
23export interface RegistryOptions {
24 fallback?: RegistryReader;
25}
26export interface RegistryAccessor extends RegistryReader, RegistryWriter {
27}
28export default class Registry implements RegistryAccessor {
29 private _registrations;
30 private _registeredOptions;
31 private _registeredInjections;
32 private _fallback;
33 constructor(options?: RegistryOptions);
34 register(specifier: string, factoryDefinition: FactoryDefinition<any>, options?: RegistrationOptions): void;
35 registration(specifier: string): FactoryDefinition<any>;
36 unregister(specifier: string): void;
37 registerOption(specifier: string, option: string, value: any): void;
38 registeredOption(specifier: string, option: string): any;
39 registeredOptions(specifier: string): any;
40 unregisterOption(specifier: string, option: string): void;
41 registerInjection(specifier: string, property: string, source: string): void;
42 registeredInjections(specifier: string): Injection[];
43}