MCPcopy
hub / github.com/loopbackio/loopback-next / onStart

Method onStart

packages/core/src/application.ts:379–389  ·  view source on GitHub ↗

* 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>)

Source from the content-addressed store, hash-verified

377 * @returns The LifeCycleObserver binding created.
378 */
379 public onStart(fn: () => ValueOrPromise<void>): Binding<LifeCycleObserver> {
380 const key = [
381 CoreBindings.LIFE_CYCLE_OBSERVERS,
382 fn.name || '<onStart>',
383 generateUniqueId(),
384 ].join('.');
385
386 return this.bind<LifeCycleObserver>(key)
387 .to({start: fn})
388 .apply(asLifeCycleObserver);
389 }
390
391 /**
392 * Stop the application instance and all of its registered observers. The

Callers 1

Calls 3

applyMethod · 0.80
toMethod · 0.80
bindMethod · 0.45

Tested by

no test coverage detected