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

Method lifeCycleObserver

packages/core/src/application.ts:503–516  ·  view source on GitHub ↗

* Register a life cycle observer class * @param ctor - A class implements LifeCycleObserver * @param nameOrOptions - Optional name or options for the life cycle observer

(
    ctor: Constructor<T>,
    nameOrOptions?: string | BindingFromClassOptions,
  )

Source from the content-addressed store, hash-verified

501 * @param nameOrOptions - Optional name or options for the life cycle observer
502 */
503 public lifeCycleObserver<T extends LifeCycleObserver>(
504 ctor: Constructor<T>,
505 nameOrOptions?: string | BindingFromClassOptions,
506 ): Binding<T> {
507 this.debug('Adding life cycle observer %s', nameOrOptions ?? ctor.name);
508 const binding = createBindingFromClass(ctor, {
509 namespace: CoreBindings.LIFE_CYCLE_OBSERVERS,
510 type: CoreTags.LIFE_CYCLE_OBSERVER,
511 defaultScope: BindingScope.SINGLETON,
512 ...toOptions(nameOrOptions),
513 }).apply(asLifeCycleObserver);
514 this.add(binding);
515 return binding;
516 }
517
518 /**
519 * Add a service to this application.

Callers 6

mainFunction · 0.95
mountComponentFunction · 0.80
loadMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80

Calls 5

createBindingFromClassFunction · 0.90
applyMethod · 0.80
toOptionsFunction · 0.70
addMethod · 0.65
debugMethod · 0.45

Tested by 1

mainFunction · 0.76