From eb400acbbd7277805697ac0d304d42e22037e239 Mon Sep 17 00:00:00 2001 From: "Micael Levi L. Cavalcante" Date: Mon, 26 Aug 2024 08:11:51 -0400 Subject: [PATCH] docs(fundamentals): improve factory provider examples --- content/fundamentals/dependency-injection.md | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/content/fundamentals/dependency-injection.md b/content/fundamentals/dependency-injection.md index ef54e9dc59..62687d9257 100644 --- a/content/fundamentals/dependency-injection.md +++ b/content/fundamentals/dependency-injection.md @@ -242,20 +242,20 @@ The `useFactory` syntax allows for creating providers **dynamically**. The actua @@filename() const connectionProvider = { provide: 'CONNECTION', - useFactory: (optionsProvider: OptionsProvider, optionalProvider?: string) => { + useFactory: (optionsProvider: MyOptionsProvider, optionalProvider?: string) => { const options = optionsProvider.get(); return new DatabaseConnection(options); }, - inject: [OptionsProvider, { token: 'SomeOptionalProvider', optional: true }], - // \_____________/ \__________________/ - // This provider The provider with this - // is mandatory. token can resolve to `undefined`. + inject: [MyOptionsProvider, { token: 'SomeOptionalProvider', optional: true }], + // \______________/ \__________________/ + // This provider The provider with this token + // is mandatory. can resolve to `undefined`. }; @Module({ providers: [ connectionProvider, - OptionsProvider, + MyOptionsProvider, // class-based provider // { provide: 'SomeOptionalProvider', useValue: 'anything' }, ], }) @@ -267,16 +267,16 @@ const connectionProvider = { const options = optionsProvider.get(); return new DatabaseConnection(options); }, - inject: [OptionsProvider, { token: 'SomeOptionalProvider', optional: true }], - // \_____________/ \__________________/ - // This provider The provider with this - // is mandatory. token can resolve to `undefined`. + inject: [MyOptionsProvider, { token: 'SomeOptionalProvider', optional: true }], + // \______________/ \__________________/ + // This provider The provider with this token + // is mandatory. can resolve to `undefined`. }; @Module({ providers: [ connectionProvider, - OptionsProvider, + MyOptionsProvider, // class-base provider // { provide: 'SomeOptionalProvider', useValue: 'anything' }, ], })