fluxject
Version:
A strongly-typed dependency injection library.
35 lines (34 loc) • 2.34 kB
TypeScript
/** @import * as Types from "./types.js" */
export class RegistrationBuilder {
/**
* Register a new set of dependencies with the lifetime of "scoped".
* @template {Record<string, Types.Instantiator<any>>} TInstantiators
* Inferred instantiators from `newRegistrations`
* @param {TInstantiators} newRegistrations
* An object containing the new registrations to add, where the values are class constructors or factory functions.
* @returns {{[K in keyof TInstantiators]: Types.Registration<TInstantiators[K], "scoped">}}
* A new set of registrations with the lifetime of "scoped".
*/
scoped<TInstantiators extends Record<string, Types.Instantiator<any>>>(newRegistrations: TInstantiators): { [K in keyof TInstantiators]: Types.Registration<TInstantiators[K], "scoped">; };
/**
* Register a new set of dependencies with the lifetime of "singleton".
* @template {Record<string, Types.Instantiator<any>>} TInstantiators
* Inferred instantiators from `newRegistrations`
* @param {TInstantiators} newRegistrations
* An object containing the new registrations to add, where the values are class constructors or factory functions.
* @returns {{[K in keyof TInstantiators]: Types.Registration<TInstantiators[K], "singleton">}}
* A new set of registrations with the lifetime of "singleton".
*/
singleton<TInstantiators extends Record<string, Types.Instantiator<any>>>(newRegistrations: TInstantiators): { [K in keyof TInstantiators]: Types.Registration<TInstantiators[K], "singleton">; };
/**
* Register a new set of dependencies with
* @template {Record<string, Types.Instantiator<any>>} TInstantiators
* Inferred instantiators from `newRegistrations`
* @param {TInstantiators} newRegistrations
* An object containing the new registrations to add, where the values are class constructors or factory functions.
* @returns {{[K in keyof TInstantiators]: Types.Registration<TInstantiators[K], "transient">}}
* A new set of registrations with the lifetime of "transient".
*/
transient<TInstantiators extends Record<string, Types.Instantiator<any>>>(newRegistrations: TInstantiators): { [K in keyof TInstantiators]: Types.Registration<TInstantiators[K], "transient">; };
}
import type * as Types from "./types.js";