MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / onInit

Method onInit

packages/core/src/application.ts:333–343  ·  view source on GitHub ↗

* Register a function to be called when the application initializes. * * This is a shortcut for adding a binding for a LifeCycleObserver * implementing a `init()` method. * * @param fn The function to invoke, it can be synchronous (returning `void`) * or asynchronous (returning `Pr

(fn: () => ValueOrPromise<void>)

Source from the content-addressed store, hash-verified

331 * @returns The LifeCycleObserver binding created.
332 */
333 public onInit(fn: () => ValueOrPromise<void>): Binding<LifeCycleObserver> {
334 const key = [
335 CoreBindings.LIFE_CYCLE_OBSERVERS,
336 fn.name || '<onInit>',
337 generateUniqueId(),
338 ].join('.');
339
340 return this.bind<LifeCycleObserver>(key)
341 .to({init: fn})
342 .apply(asLifeCycleObserver);
343 }
344
345 /**
346 * Start the application, and all of its registered observers. The application

Callers 1

Calls 3

applyMethod · 0.80
toMethod · 0.80
bindMethod · 0.45

Tested by

no test coverage detected