Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface FactoryProvider<T>

Interface defining a Factory type provider.

For example:

const connectionFactory = {
  provide: 'CONNECTION',
  useFactory: (optionsProvider: OptionsProvider) => {
    const options = optionsProvider.get();
    return new DatabaseConnection(options);
  },
  inject: [OptionsProvider],
};
see

Use factory

see

Injection scopes

publicapi

Type parameters

  • T = any

Hierarchy

  • FactoryProvider

Index

Properties

Optional inject

inject: Array<Type<any> | string | symbol | Abstract<any> | Function>

Optional list of providers to be injected into the context of the Factory function.

provide

provide: string | symbol | Type<any> | Abstract<any> | Function

Injection token

Optional scope

scope: Scope

Optional enum defining lifetime of the provider that is returned by the Factory function.

useFactory

useFactory: (...args: any[]) => T

Factory function that returns an instance of the provider to be injected.

Type declaration

    • (...args: any[]): T
    • Parameters

      • Rest ...args: any[]

      Returns T

Generated using TypeDoc