Skip to content

ServiceMixin

The ServiceMixin function enables you to easily create and maintain classes that follow the Singleton design pattern. Singleton classes are useful for creating services that should only have one instance in your application at any given time. They provide a way to share state and functionality across your application without the need for global variables or framework-specific state management engines.

Functions

ServiceMixin()

ServiceMixin<TService>(): typeof Service

Defined in: service-mixin.ts:11

Extending ServiceMixin will turn the inheriting class into a singleton class.

Type Parameters

TService

The type of the service.

Returns

typeof Service

A parent class that turns the inheriting class into a singleton class.

See

https://en.wikipedia.org/wiki/Singleton_pattern

Example

class MyService extends ServiceMixin<MyService>() {
// ...
}