Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rename
NgxMatomoRouterModule
to MatomoRouterModule
DEPRECATION: `NgxMatomoRouterModule` has been deprecated, use `MatomoRouterModule` instead
- Loading branch information
1 parent
eb70405
commit 8795a05
Showing
3 changed files
with
75 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core'; | ||
import { ɵMATOMO_ROUTER_ENABLED as MATOMO_ROUTER_ENABLED } from 'ngx-matomo-client/core'; | ||
import { | ||
MATOMO_ROUTER_CONFIGURATION, | ||
MatomoRouterConfigurationWithInterceptors, | ||
} from './configuration'; | ||
import { provideInterceptors } from './interceptor'; | ||
import { MatomoRouter } from './matomo-router.service'; | ||
|
||
@NgModule({ | ||
providers: [{ provide: MATOMO_ROUTER_ENABLED, useValue: true }], | ||
}) | ||
export class MatomoRouterModule { | ||
constructor( | ||
private readonly router: MatomoRouter, | ||
@Optional() @SkipSelf() parent?: MatomoRouterModule, | ||
@Optional() @SkipSelf() parentDeprecated?: NgxMatomoRouterModule | ||
) { | ||
if (!parent && !parentDeprecated) { | ||
// Do not initialize if it is already (by a parent module) | ||
this.router.initialize(); | ||
} | ||
} | ||
|
||
static forRoot( | ||
configWithInterceptors: MatomoRouterConfigurationWithInterceptors = {} | ||
): ModuleWithProviders<MatomoRouterModule> { | ||
// Note: not using "rest" syntax here, in order to avoid any dependency on tslib (and reduce package size) | ||
// The only drawback of this is that MATOMO_ROUTER_CONFIGURATION will actually | ||
// contain a reference to provided interceptors | ||
return { | ||
ngModule: MatomoRouterModule, | ||
providers: [ | ||
{ provide: MATOMO_ROUTER_CONFIGURATION, useValue: configWithInterceptors }, | ||
provideInterceptors(configWithInterceptors.interceptors), | ||
], | ||
}; | ||
} | ||
} | ||
|
||
/** | ||
* @deprecated use MatomoRouterModule instead | ||
* @breaking-change 7.0.0 | ||
*/ | ||
@NgModule({ | ||
providers: [{ provide: MATOMO_ROUTER_ENABLED, useValue: true }], | ||
}) | ||
export class NgxMatomoRouterModule { | ||
constructor( | ||
private readonly router: MatomoRouter, | ||
@Optional() @SkipSelf() parent?: MatomoRouterModule, | ||
@Optional() @SkipSelf() parentDeprecated?: NgxMatomoRouterModule | ||
) { | ||
if (!parent && !parentDeprecated) { | ||
// Do not initialize if it is already (by a parent module) | ||
this.router.initialize(); | ||
} | ||
} | ||
|
||
static forRoot( | ||
configWithInterceptors: MatomoRouterConfigurationWithInterceptors = {} | ||
): ModuleWithProviders<NgxMatomoRouterModule> { | ||
// Note: not using "rest" syntax here, in order to avoid any dependency on tslib (and reduce package size) | ||
// The only drawback of this is that MATOMO_ROUTER_CONFIGURATION will actually | ||
// contain a reference to provided interceptors | ||
return { | ||
ngModule: NgxMatomoRouterModule, | ||
providers: [ | ||
{ provide: MATOMO_ROUTER_CONFIGURATION, useValue: configWithInterceptors }, | ||
provideInterceptors(configWithInterceptors.interceptors), | ||
], | ||
}; | ||
} | ||
} |
38 changes: 0 additions & 38 deletions
38
projects/ngx-matomo-client/router/ngx-matomo-router.module.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters