* Stop the application instance and all of its registered observers. The * application state is checked to ensure the integrity of `stop`. * * If the application is already stopped or not started, no operation is * performed.
()
| 396 | * performed. |
| 397 | */ |
| 398 | public async stop(): Promise<void> { |
| 399 | if (this._state === 'stopping') return this.awaitState('stopped'); |
| 400 | this.assertNotInProcess('stop'); |
| 401 | // No-op if it's created or stopped |
| 402 | if (this._state !== 'started' && this._state !== 'initialized') return; |
| 403 | this.setState('stopping'); |
| 404 | if (!this._isShuttingDown) { |
| 405 | // Explicit stop is called, let's remove signal listeners to avoid |
| 406 | // memory leak and max listener warning |
| 407 | this.removeSignalListener(); |
| 408 | } |
| 409 | const registry = await this.getLifeCycleObserverRegistry(); |
| 410 | await registry.stop(); |
| 411 | this.setState('stopped'); |
| 412 | } |
| 413 | |
| 414 | /** |
| 415 | * Register a function to be called when the application starts. |
no test coverage detected