Module
Type parameters
▪ T: SuperConstructor
▪ T: SuperConstructor
Hierarchy
SuperPrototypeSelector‹StatefulMixin, this› & StatefulMixin‹this›
SuperPrototypeSelector‹StatefulMixin, this› & StatefulMixin‹this›
↳ Module
↳ BaseApp
↳ Eveble
↳ AgendaCommandSchedulerModule
Implements
Index
Constructors
Properties
Methods
- getSelectableStates
- getState
- hasState
- initialize
- invokeAction
- isInDevelopment
- isInOneOfStates
- isInProduction
- isInState
- reset
- setState
- shutdown
- start
- stop
- validateState
Constructors
constructor
+ new Module(props?
: ModuleProps): Module
Creates an instance of Module. Creates an instance of Module.
Parameters:
Name | Type | Description |
---|---|---|
props? | ModuleProps | Properties 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
Returns: State
hasState
▸ hasState(): boolean
Implementation of Module
Inherited from StatefulMixin.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:
Name | Type | Description |
---|---|---|
app | BaseApp | Application that requires(depends) module. |
injector | Injector | IoC 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:
Name | Type | Description |
---|---|---|
actionName | string | Name of action(function) to run. |
options? | ActionInvokingOptions | Additional 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:
Name | Type |
---|---|
states | State | 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
Parameters:
Name | Type |
---|---|
state | State | 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
Parameters:
Name | Type |
---|---|
state | State |
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:
Name | Type |
---|---|
stateOrStates | State | State[] |
error? | Error |
Returns: boolean