App
Type parameters
▪ T: SuperConstructor
▪ T: SuperConstructor
Hierarchy
↳ BaseApp
BaseApp
↳ App
Implements
Index
Constructors
Properties
Methods
- afterShutdown
- configure
- debug
- getSelectableStates
- getState
- hasState
- initialize
- invokeAction
- isCommandScheduling
- isInDevelopment
- isInOneOfStates
- isInProduction
- isInState
- isSnapshotting
- onProcessSignal
- publish
- reset
- send
- setState
- shutdown
- start
- stop
- subscribeTo
- validateState
Constructors
constructor
+ new App(props?
: ModuleProps & object): App
Overrides BaseApp.constructor
Creates an instance of App. Creates an instance of App.
Parameters:
Name | Type | Description |
---|---|---|
props? | ModuleProps & object | Properties for App. |
Returns: App
Properties
Optional
app
• app? : BaseApp
Overrides void
config
• config: AppConfig
Implementation of BaseApp.config
Readonly
envFilePath
• envFilePath: string
injector
• injector: Injector
Implementation of BaseApp.injector
log
• log: Logger
modules
• modules: Module[]
state
• state: State
Implementation of BaseApp.state
Inherited from StatefulMixin.state
Overrides void
Static
STATES
▪ STATES: typeof STATES
Overrides void
Methods
afterShutdown
▸ afterShutdown(): Promise‹void›
Inherited from BaseApp.afterShutdown
Overrides void
Returns: Promise‹void›
configure
▸ configure(props
: ConfigProps): void
Inherited from BaseApp.configure
Overrides void
Parameters:
Name | Type |
---|---|
props | ConfigProps |
Returns: void
debug
▸ debug(): void
Overrides void
Returns: void
getSelectableStates
▸ getSelectableStates(): Record‹string, State›
Implementation of BaseApp
Inherited from StatefulMixin.getSelectableStates
Overrides Task.getSelectableStates
Returns: Record‹string, State›
getState
▸ getState(): State
Implementation of BaseApp
Inherited from StatefulMixin.getState
Returns: State
hasState
▸ hasState(): boolean
Implementation of BaseApp
Inherited from StatefulMixin.hasState
Returns: boolean
initialize
▸ initialize(): Promise‹void›
Implementation of BaseApp
Inherited from BaseApp.initialize
Overrides Module.initialize
Returns: Promise‹void›
invokeAction
▸ invokeAction(actionName
: string, options?
: ActionInvokingOptions): Promise‹void›
Implementation of BaseApp
Inherited from Module.invokeAction
Overrides void
Parameters:
Name | Type |
---|---|
actionName | string |
options? | ActionInvokingOptions |
Returns: Promise‹void›
isCommandScheduling
▸ isCommandScheduling(): boolean
Evaluates if application has CommandScheduler
enabled.
Returns: boolean
Returns true
if command scheduling is enabled on application, else false
.
isInDevelopment
▸ isInDevelopment(): boolean
Inherited from Module.isInDevelopment
Overrides void
Returns: boolean
isInOneOfStates
▸ isInOneOfStates(states
: State | State[]): boolean
Implementation of BaseApp
Inherited from StatefulMixin.isInOneOfStates
Overrides Task.isInOneOfStates
Parameters:
Name | Type |
---|---|
states | State | State[] |
Returns: boolean
isInProduction
▸ isInProduction(): boolean
Overrides Module.isInProduction
Evaluates if app is running on production.
Returns: boolean
Returns true
if application is running on production environment, else false
.
isInState
▸ isInState(state
: State | State[]): boolean
Implementation of BaseApp
Inherited from StatefulMixin.isInState
Parameters:
Name | Type |
---|---|
state | State | State[] |
Returns: boolean
isSnapshotting
▸ isSnapshotting(): boolean
Evaluates if application has Snapshotter
enabled.
Returns: boolean
Returns true
if snapshotting is enabled on application, else fal`se.
onProcessSignal
▸ onProcessSignal(code
: NodeJS.Signals): Promise‹void›
On process signal hook for graceful shutdown.
async
Parameters:
Name | Type | Description |
---|---|---|
code | NodeJS.Signals | Node's signal process code. |
Returns: Promise‹void›
publish
▸ publish(event
: Event): Promise‹void›
Publishes event through EventBus
.
async
Parameters:
Name | Type | Description |
---|---|---|
event | Event | Instance implementing Event interface. |
Returns: Promise‹void›
reset
▸ reset(): Promise‹void›
Implementation of BaseApp
Overrides void
Returns: Promise‹void›
send
▸ send(command
: Command): Promise‹any›
Sends command through CommandBus
.
async
throws
{HandlerNotFoundError}
Thrown if handler for message type is not found.
Parameters:
Name | Type | Description |
---|---|---|
command | Command | Instance implementing Command interface. |
Returns: Promise‹any›
Result of handling command.
setState
▸ setState(state
: State): void
Implementation of BaseApp
Inherited from StatefulMixin.setState
Parameters:
Name | Type |
---|---|
state | State |
Returns: void
shutdown
▸ shutdown(): Promise‹void›
Implementation of BaseApp
Inherited from BaseApp.shutdown
Returns: Promise‹void›
start
▸ start(): Promise‹void›
Implementation of BaseApp
Overrides void
Returns: Promise‹void›
stop
▸ stop(): Promise‹void›
Implementation of BaseApp
Overrides void
Returns: Promise‹void›
subscribeTo
▸ subscribeTo(eventType
: MessageType‹Event›, handler
: Handler): Promise‹void›
Subscribes to event type with handler.
async
Parameters:
Name | Type | Description |
---|---|---|
eventType | MessageType‹Event› | - |
handler | Handler | Handler function that will executed upon published Event . |
Returns: Promise‹void›
validateState
▸ validateState(stateOrStates
: State | State[], error?
: Error): boolean
Implementation of BaseApp
Inherited from StatefulMixin.validateState
Overrides Task.validateState
Parameters:
Name | Type |
---|---|
stateOrStates | State | State[] |
error? | Error |
Returns: boolean