Page Contents

Home > @loopback/core > Application > onInit

Application.onInit() method

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.

Signature:

onInit(fn: () => ValueOrPromise<void>): Binding<LifeCycleObserver>;

Parameters

Parameter Type Description
fn () => ValueOrPromise<void> The function to invoke, it can be synchronous (returning void) or asynchronous (returning Promise<void>).

Returns:

Binding<LifeCycleObserver>

The LifeCycleObserver binding created.