Optional
apply: ((self, args) => InstanceType<T>)The callback to apply
on subsequent new
invocations.
A class constructor decorator.
Singleton class:
import { Singleton } from '@sgrud/core';
@Singleton()
export class Service {}
new Service() === new Service(); // true
Generated using TypeDoc
Class decorator factory. Enforces a transparent Singleton pattern on the decorated class. When calling the
new
operator on a decorated class for the first time, an instance of the decorated class is created using the supplied arguments, if any. This instance will remain the Singleton instance of the decorated class indefinitely. When calling thenew
operator on a decorated class already instantiated, the Singleton pattern is enforced and the previously constructed instance is returned. Instead, if provided, theapply
callback is fired with the Singleton instance and thenew
invocation parameters.