Module

Type parameters

▪ T: SuperConstructor

▪ T: SuperConstructor

Hierarchy

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

+ new Module(props?: ModuleProps): Module

Creates an instance of Module. Creates an instance of Module.

Parameters:

NameTypeDescription
props?ModulePropsProperties matching module definition.

Returns: Module

Properties

Optional app

• app? : BaseApp


config

• config: Configurable

Implementation of Module.config


injector

• injector: Injector


Optional log

• log? : Logger


modules

• modules: Module[]


state

• state: State

Implementation of Module.state

Inherited from StatefulMixin.state

Overrides void


Static STATES

▪ STATES: STATES = STATES

Methods

getSelectableStates

▸ getSelectableStates(): Record‹string, State›

Implementation of Module

Inherited from StatefulMixin.getSelectableStates

Overrides Task.getSelectableStates

Returns: Record‹string, State›


getState

▸ getState(): State

Implementation of Module

Inherited from StatefulMixin.getState

Overrides Task.getState

Returns: State


hasState

▸ hasState(): boolean

Implementation of Module

Inherited from StatefulMixin.hasState

Overrides Task.hasState

Returns: boolean


initialize

▸ initialize(app: BaseApp, injector: Injector): Promise‹void›

Implementation of Module

Initializes module.

async

throws {AppMissingError} Thrown if the app argument is missing.

throws {InjectorMissingError} Thrown if the injector argument is missing.

Parameters:

NameTypeDescription
appBaseAppApplication that requires(depends) module.
injectorInjectorIoC container implementing Inversifiy's Containers interface.

Returns: Promise‹void›


invokeAction

▸ invokeAction(actionName: string, options?: ActionInvokingOptions): Promise‹void›

Implementation of Module

Runs action on module if action is defined.

async

Parameters:

NameTypeDescription
actionNamestringName of action(function) to run.
options?ActionInvokingOptionsAdditional options for behavior of invoking action.

Returns: Promise‹void›


isInDevelopment

▸ isInDevelopment(): boolean

Evaluates if current environment is on development.

Returns: boolean

Returns true if is on development environment, else false.


isInOneOfStates

▸ isInOneOfStates(states: State | State[]): boolean

Implementation of Module

Inherited from StatefulMixin.isInOneOfStates

Overrides Task.isInOneOfStates

Parameters:

NameType
statesState | State[]

Returns: boolean


isInProduction

▸ isInProduction(): boolean

Evaluates if current environment is on production.

Returns: boolean

Returns true if is on production environment, else false.


isInState

▸ isInState(state: State | State[]): boolean

Implementation of Module

Inherited from StatefulMixin.isInState

Overrides Task.isInState

Parameters:

NameType
stateState | State[]

Returns: boolean


reset

▸ reset(): Promise‹void›

Implementation of Module

Restarts module state and invokes all associated lifecycle hooks.

async

throws {InvalidStateError} Thrown if the module is not in one of states: 'initialized', 'stopped', 'running'.

throws {InvalidEnvironmentError} Thrown if resetting is done on production environment.

Returns: Promise‹void›


setState

▸ setState(state: State): void

Implementation of Module

Inherited from StatefulMixin.setState

Overrides Task.setState

Parameters:

NameType
stateState

Returns: void


shutdown

▸ shutdown(): Promise‹void›

Implementation of Module

Shutdowns module and changes state to 'shutdown' and invokes lifecycle 'shutdown' action.

async

throws {InvalidStateError} Thrown if the module is not in one of states: 'initialized', 'stopped', 'running', 'shutdown'.

Returns: Promise‹void›


start

▸ start(): Promise‹void›

Implementation of Module

Changes module state to 'running' and invokes lifecycle 'start' action.

async

throws {InvalidStateError} Thrown if the module is not in one of states: 'initialized', 'stopped', 'running'.

Returns: Promise‹void›


stop

▸ stop(): Promise‹void›

Implementation of Module

Changes module state to 'stopped' and invokes lifecycle 'stop' action.

async

throws {InvalidStateError} Thrown if the module is not in one of states: 'initialized', 'stopped', 'running'.

Returns: Promise‹void›


validateState

▸ validateState(stateOrStates: State | State[], error?: Error): boolean

Implementation of Module

Inherited from StatefulMixin.validateState

Overrides Task.validateState

Parameters:

NameType
stateOrStatesState | State[]
error?Error

Returns: boolean