UNPKG

fluxject

Version:

A strongly-typed dependency injection library.

20 lines (19 loc) 859 B
/** * Object that allows for services to be lazily instantiated. * * - Singleton and Scoped services will store their instance after the first property access. * - Transient services will dispose of their instance immediately after the first property access. * - If the property accessor was a function, the instance will be disposed of after the function is invoked. * @template TInstanceType */ export class LazyReference<TInstanceType> { /** * Create a new lazy reference to an instance * @param {() => TInstanceType} instantiator * The function that will be used to instantiate the reference. * @param {boolean} isTransient * True if the reference is transient (will be disposed of after property de-referencing) */ constructor(instantiator: () => TInstanceType, isTransient: boolean); #private; }