angular/packages/core/schematics/migrations/provide-initializer
2025-01-09 10:27:54 -05:00
..
BUILD.bazel feat(core): add syntactic sugar for initializers (#53152) 2024-10-22 09:38:18 -07:00
index.ts feat(core): add syntactic sugar for initializers (#53152) 2024-10-22 09:38:18 -07:00
README.md feat(core): add syntactic sugar for initializers (#53152) 2024-10-22 09:38:18 -07:00
utils.ts docs: update license URL from angular.io to angular.dev and year of license to 2025 (#59407) 2025-01-09 10:27:54 -05:00

Replace APP_INITIALIZER, ENVIRONMENT_INITIALIZER, and PLATFORM_INITIALIZER with provider functions

Replaces APP_INITIALIZER, ENVIRONMENT_INITIALIZER, and PLATFORM_INITIALIZER with their respective provider functions: provideAppInitializer, provideEnvironmentInitializer, and providePlatformInitializer.

Before

import {APP_INITIALIZER} from '@angular/core';

const providers = [
  {
    provide: APP_INITIALIZER,
    useValue: () => { console.log('hello'); },
    multi: true,
  }
];

After

import {provideAppInitializer} from '@angular/core';

const providers = [provideAppInitializer(() => { console.log('hello'); })];