* Register a function to be called when the application starts. * * This is a shortcut for adding a binding for a LifeCycleObserver * implementing a `start()` method. * * @param fn The function to invoke, it can be synchronous (returning `void`) * or asynchronous (returning `Promis
(fn: () => ValueOrPromise<void>)
| 422 | * @returns The LifeCycleObserver binding created. |
| 423 | */ |
| 424 | public onStop(fn: () => ValueOrPromise<void>): Binding<LifeCycleObserver> { |
| 425 | const key = [ |
| 426 | CoreBindings.LIFE_CYCLE_OBSERVERS, |
| 427 | fn.name || '<onStop>', |
| 428 | generateUniqueId(), |
| 429 | ].join('.'); |
| 430 | return this.bind<LifeCycleObserver>(key) |
| 431 | .to({stop: fn}) |
| 432 | .apply(asLifeCycleObserver); |
| 433 | } |
| 434 | |
| 435 | private async getLifeCycleObserverRegistry() { |
| 436 | return this.get(CoreBindings.LIFE_CYCLE_OBSERVER_REGISTRY); |
no test coverage detected