Lifecycle hooks

February 8, 2023 ยท View on GitHub

You can use any of the Luigi lifecycle hooks by adding additional setup to the root of the Luigi configuration object. Here is an example:

{
  ...
  lifecycleHooks: {
    luigiAfterInit: () => {
      // initializing with a different language
      myGeoLocationService.getLanguage().then(lang => {
        Luigi.i18n().setCurrentLocale(lang);
      })
    }
  }
  ...
}

luigiAfterInit()

This method will be called after Luigi.setConfig({}) is executed.

Keep in mind that luigiAfterInitis only triggered after the first setConfig instance. If you need it to be fired again, you can use Luigi.reset() to trigger a new Luigi re-initialization.