add header comment for api methods

This commit is contained in:
Robin Chappatte
2024-05-31 14:58:32 +02:00
parent bd7d2aae65
commit 777d8605a0

View File

@@ -16,7 +16,14 @@ export class DependencyManager {
private modules: Modules = new Map();
private resolving: Set<ModuleIdentifier> = new Set();
// Enregistrer un module avec son initialisateur
/**
* Set the given provider to be used to resolve the dependency identified by the given identifier.
*
* Throw an error if the identifier is already used.
*
* @param identifier the identifier that will be used to ask the manager for the resolved dependency.
* @param provider a function that receive the dependency manager as param and return the dependency. Can be asynchronous.
*/
register<T>(identifier: ModuleIdentifier, provider: Provider<T>): void {
if (this.modules.has(identifier)) {
throw new Error(`Module ${identifier} is already registered.`);
@@ -24,7 +31,16 @@ export class DependencyManager {
this.modules.set(identifier, { provider });
}
// Résoudre un module et ses dépendances
/**
* Return the dependency matching the given identifier.
* If the dependency has not been resolved yet, resolve it first.
*
* Throw an error if:
* - no provider has been registred with that identifier
* - a circular dependency is detected
*
* @param identifier the identifier used to register the provider
*/
async resolve<T>(identifier: ClassType<T>): Promise<T>;
async resolve<T>(identifier: ModuleIdentifier): Promise<T>;
async resolve(identifier: ModuleIdentifier) {