Skip to content

Commit

Permalink
refactor: simplify provider setup
Browse files Browse the repository at this point in the history
  • Loading branch information
json-derulo committed Nov 14, 2024
1 parent 75021c3 commit 0134919
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@ import { MaterialCssVarsService } from "./material-css-vars.service";
@NgModule({
imports: [CommonModule],
})
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export class MaterialCssVarsModule {
static forRoot(
config?: Partial<MaterialCssVariablesConfig>,
): ModuleWithProviders<MaterialCssVarsModule> {
return {
ngModule: MaterialCssVarsModule,
providers: [{ provide: MATERIAL_CSS_VARS_CFG, useValue: config }],
providers: [provideMaterialCssVars(config)],
};
}

// This is necessary, so the service is constructed, even if the service is never injected
// ToDo: change to environment initializer, like in the provideMaterialCssVars() function below
constructor(private materialCssVarsService: MaterialCssVarsService) {}
}

export function provideMaterialCssVars(
Expand Down

0 comments on commit 0134919

Please sign in to comment.