Skip to content

Commit

Permalink
feat: change provider API to return environment providers (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlj95 authored Oct 2, 2024
1 parent c1212b7 commit 2d84e04
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion projects/ngx-meta/api-extractor/ngx-meta.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export const provideNgxMetaOpenGraph: () => Provider[];
export const provideNgxMetaOpenGraphProfile: () => Provider[];

// @public
export const provideNgxMetaRouting: () => Provider[];
export const provideNgxMetaRouting: () => EnvironmentProviders;

// @public
export const provideNgxMetaStandard: () => Provider[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class NgxMetaRoutingModule {
static forRoot(): ModuleWithProviders<NgxMetaRoutingModule> {
return {
ngModule: NgxMetaRoutingModule,
providers: provideNgxMetaRouting(),
providers: [provideNgxMetaRouting()],
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { ENVIRONMENT_INITIALIZER, inject, Provider } from '@angular/core'
import {
ENVIRONMENT_INITIALIZER,
EnvironmentProviders,
inject,
makeEnvironmentProviders,
} from '@angular/core'
import { _ROUTE_METADATA_STRATEGY } from '@davidlj95/ngx-meta/core'
import { DEFAULT_ROUTE_METADATA_STRATEGY } from '../route-metadata/default-route-metadata-strategy'
import { ROUTER_LISTENER } from '../listener/router-listener'
Expand All @@ -14,14 +19,15 @@ import { ROUTER_LISTENER } from '../listener/router-listener'
*
* @public
*/
export const provideNgxMetaRouting = (): Provider[] => [
{
provide: _ROUTE_METADATA_STRATEGY,
useExisting: DEFAULT_ROUTE_METADATA_STRATEGY,
},
{
provide: ENVIRONMENT_INITIALIZER,
multi: true,
useFactory: () => inject(ROUTER_LISTENER).listen,
},
]
export const provideNgxMetaRouting = (): EnvironmentProviders =>
makeEnvironmentProviders([
{
provide: _ROUTE_METADATA_STRATEGY,
useExisting: DEFAULT_ROUTE_METADATA_STRATEGY,
},
{
provide: ENVIRONMENT_INITIALIZER,
multi: true,
useFactory: () => inject(ROUTER_LISTENER).listen,
},
])

0 comments on commit 2d84e04

Please sign in to comment.