Skip to content

An Angular DI token that you can use to provide one or more initialization functions that will be executed in order

License

Notifications You must be signed in to change notification settings

ChiefWiggum/ngx-ordered-initializer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ngx-ordered-initializer

An Angular DI token that you can use to provide one or more initialization functions that will be executed in order

Installation

npm install ngx-ordered-initializer

Versions

  • Angular 11: 1.0.0
  • Angular 12: 2.0.0
  • Angular 14: 4.0.0

Usage

import { APP_INITIALIZER, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {
  ORDERED_APP_INITIALIZER,
  ORDERED_APP_PROVIDER,
} from 'ngx-ordered-initializer';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, HttpClientModule],
  providers: [
    {
      provide: ORDERED_APP_INITIALIZER,
      useFactory: initializer1,
      multi: true,
    },
    {
      provide: ORDERED_APP_INITIALIZER,
      useFactory: initializer2,
      multi: true,
    },
    ORDERED_APP_PROVIDER,
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}

The ORDERED_APP_PROVIDER will ensure that each initializer provided as ORDERED_APP_INITIALIZER will be executed in the declaration order.

Demo

https://stackblitz.com/edit/ngx-ordered-initializer-demo

About

An Angular DI token that you can use to provide one or more initialization functions that will be executed in order

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%