Class

Injectables

Injectables()

Constructor

# new Injectables()

Static class holding the access to the injectables functions. Provides methods for registering, retrieving, and building injectable objects.

Central registry for managing injectable dependencies.

sequenceDiagram participant Client participant Injectables participant Registry Client->>Injectables: register(MyService) Injectables->>Registry: register(MyService) Registry-->>Injectables: void Client->>Injectables: get("MyService") Injectables->>Registry: get("MyService") Registry-->>Injectables: MyService instance Injectables-->>Client: MyService instance

View Source Injectables.ts, line 3

Example
// Define an injectable class

Methods

# static build(obj, args) → {T}

Instantiates an injectable class using its constructor and the provided arguments.

Creates a new instance of an injectable class.

Parameters:
Name Type Description
obj Record.<string, any>

Object containing the name of the injectable to build

args Array.<any>

Constructor arguments to pass when instantiating the injectable

View Source Injectables.ts, line 157

The newly created instance

T

# static get(name, args) → {Injectable.<T>|undefined}

Retrieves the named Injectable from the registry. If the injectable is a singleton, returns the existing instance. Otherwise, creates a new instance.

Fetches an injectable instance by its registered name.

Parameters:
Name Type Description
name string

The registered name of the injectable to retrieve

args Array.<any>

Constructor arguments to pass when instantiating the injectable

View Source Injectables.ts, line 137

The injectable instance or undefined if not found

Injectable.<T> | undefined

# static getRegistry() → {InjectablesRegistry}

Returns the current InjectablesRegistry or creates a default one if none exists.

Provides access to the current registry instance.

View Source Injectables.ts, line 96

The current registry instance

InjectablesRegistry

# static register(constructor, args) → {void}

Registers an injectable constructor or instance with the registry, making it available for injection.

Adds a class or object to the injectable registry.

Parameters:
Name Type Description
constructor Injectable.<T>

The class constructor or object instance to register

args Array.<any>

Additional arguments for registration (category, singleton flag, etc.)

View Source Injectables.ts, line 147

void

# static reset() → {void}

Resets the registry to a clean state by creating a new empty registry instance.

Clears all registered injectables.

View Source Injectables.ts, line 180

void

# static selectiveReset(match) → {void}

Selectively resets the registry by removing only the injectables whose names match the provided pattern.

Removes specific injectables from the registry based on a pattern.

Parameters:
Name Type Description
match string | RegExp

A string or regular expression pattern to match against injectable names

View Source Injectables.ts, line 188

void

# static setRegistry(operationsRegistry) → {void}

Sets a new InjectablesRegistry implementation, allowing for custom registry behavior.

Replaces the current registry implementation.

Parameters:
Name Type Description
operationsRegistry InjectablesRegistry

The new implementation of Registry to use

View Source Injectables.ts, line 165

void