Defines the lifetime of a service.

  • Shared services are always the same instance.
  • Transient services are constructed each time wherever they are injected.

See Container.singleton and Container.transient to define which lifetime a class should have.

Enumeration Members

Enumeration Members

SHARED: "SHARED"

There is only one (shared) instance that is passed during injection.

See Container.singleton to register a shared service.

Example

container.singleton(MyService, [LoggerService]);
TRANSIENT: "TRANSIENT"

A new instance of the class is constructed each time it is injected.

See Container.transient to register a transient service.

Example

container.transient(LoggerService);

Generated using TypeDoc