Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Runtime

Used to construct a runtime environment for a given entry module. Handles resolving the module tree into an injector as well as constructing the module instances and running lifecycle events.

Hierarchy

  • Runtime

Index

Constructors

constructor

  • new Runtime(entryModule: Function): Runtime

Properties

definitions

definitions: ModuleDefinition[] = []

instances

instances: ModuleInstance[] = null

providers

providers: Provider[] = []

Retrieve the providers that were collected from the module graph and used to create the primary injector.

visited

visited: ModuleLike[] = []

Accessors

injector

  • get injector(): Injector
  • Get the runtime's dependency injector. This injector can provide all dependencies specified in the imported modules' providers definitions.

    Returns Injector

selfTest

  • get selfTest(): boolean
  • True if the --self-test option was used to launch the application.

    Returns boolean

Methods

configure

  • configure(): void

contributeProviders

  • contributeProviders(providers: Provider[]): void
  • Iterate over the module definitions which are part of this runtime and append to the given array the set of dependency injection providers which are specified in the module definitions.

    Parameters

    • providers: Provider[]

      An array which will be populated

    Returns void

fireEvent

  • fireEvent(eventName: string): void
  • Fire an event to all modules which understand it. Should be upper-camel-case, meaning to fire the altOnStart() method, send "OnStart".

    Parameters

    • eventName: string

    Returns void

getMetadataForModule

  • getMetadataForModule(module: ModuleLike): ModuleAnnotation
  • Retrieve the ModuleAnnotation for a given Module definition, whether it be a class annotated with @Module() or a plain object with $module which configures a module class.

    This is an alias of ModuleAnnotation.getForClass(module)

    Parameters

    • module: ModuleLike

    Returns ModuleAnnotation

getService

  • getService<T>(ctor: { constructor: any }): T
  • Get a specific service from the dependency injector.

    Type parameters

    • T

    Parameters

    • ctor: { constructor: any }
      • constructor: function
        • new __type(...args: any[]): T

    Returns T

load

  • Instantiate the modules of this runtime using the given dependency injector. The injector will be inherited into an injector that provides the dependencies specified in the imported modules' providers definitions.

    Parameters

    • injector: Injector

    Returns ModuleInstance[]

processCommandLine

  • processCommandLine(args: string[]): void

shutdown

  • shutdown(): Promise<void>
  • Stop all running services and shut down the process

    Returns Promise<void>

start

  • start(): void
  • Start any services, as defined by modules. For instance, if you import WebServerModule from @alterior/web-server, calling this will instruct the module to begin serving on the configured port.

    This will send the OnStart lifecycle event to all modules, which triggers the altOnStart() method of any module which implements it to be called. It also instructs the RolesService to start roles as per it's configuration. For more information about Roles, see the documentation for RolesService.

    Returns void

stop

  • stop(): Promise<void>
  • Stop any services, as defined by imported modules of this runtime. For instance, if you import WebServerModule from @alterior/web-server, calling this will instruct the module to stop serving on the configured port. Also builds in a timeout to allow for all services and operations to stop before resolving.

    This will send the OnStop lifecycle event to all modules, which triggers the altOnStop() method of any module which implements it to be called. It also instructs the RolesService to stop any roles which are currently running. For more information about Roles, see the documentation for RolesService.

    Returns Promise<void>

Generated using TypeDoc