Skip to main content

Class: Registry

Defined in: src/core/components/Registry.ts:3

Constructors​

Constructor​

new Registry(): Registry

Returns​

Registry

Methods​

get()​

get<T>(type): T | undefined

Defined in: src/core/components/Registry.ts:34

Gets an existing instance of a registered type.

Type Parameters​

T​

T extends object

Parameters​

type​

Constructor<T>

The constructor function of the type to retrieve.

Returns​

T | undefined

The instance of the requested type.


getOrCreate()​

getOrCreate<T>(type, factory): T

Defined in: src/core/components/Registry.ts:46

Gets an existing instance of a registered type, or creates a new one if it doesn't exist.

Type Parameters​

T​

T extends object

Parameters​

type​

Constructor<T>

The constructor function of the type to retrieve.

factory​

() => T

A function that creates a new instance of the type if it doesn't already exist.

Returns​

T

The instance of the requested type.


register()​

register<T>(instance, type?): void

Defined in: src/core/components/Registry.ts:14

Registers an new instanceof a given type. If an existing instance of the same type is already registered, it will be overwritten.

Type Parameters​

T​

T extends object

Parameters​

instance​

T

The instance to register.

type?​

Constructor<T>

Type to register the instance as. Will default to instance.constructor if not defined.

Returns​

void


unregister()​

unregister(type): void

Defined in: src/core/components/Registry.ts:69

Unregisters an instance of a given type.

Parameters​

type​

Constructor

The type to unregister.

Returns​

void