Skip to content
This repository has been archived by the owner on Jan 12, 2020. It is now read-only.

Commit

Permalink
feat(lib): add support for forRoot pattern for all modules
Browse files Browse the repository at this point in the history
  • Loading branch information
EdricChan03 committed Jun 30, 2019
1 parent 64873a3 commit e9e1704
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NgModule } from '@angular/core';
import { NgxYtdApiCommonModule } from 'ngx-ytd-api/common';
import { ModuleWithProviders, NgModule } from '@angular/core';
import { NgxYtdApiCommonModule, NgxYtdApiStandardParams, NGX_YTD_API_DEFAULT_STANDARD_PARAMS } from 'ngx-ytd-api/common';
import { NgxYtdApiCommentThreadsService } from './ytd-api-comment-threads.service';

@NgModule({
Expand All @@ -10,4 +10,20 @@ import { NgxYtdApiCommentThreadsService } from './ytd-api-comment-threads.servic
NgxYtdApiCommonModule
]
})
export class NgxYtdApiCommentThreadsModule { }
export class NgxYtdApiCommentThreadsModule {
/**
* Returns the module with the specified standard parameters
* @param defaultParams The default standard parameters
* @returns The module with the specified standard parameters
*/
static forRoot(
defaultParams: NgxYtdApiStandardParams
): ModuleWithProviders {
return {
ngModule: NgxYtdApiCommentThreadsModule,
providers: [
{ provide: NGX_YTD_API_DEFAULT_STANDARD_PARAMS, useValue: defaultParams }
]
};
}
}
22 changes: 19 additions & 3 deletions projects/ngx-ytd-api-lib/comments/src/ytd-api-comments.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NgModule } from '@angular/core';
import { NgxYtdApiCommonModule } from 'ngx-ytd-api/common';
import { ModuleWithProviders, NgModule } from '@angular/core';
import { NgxYtdApiCommonModule, NgxYtdApiStandardParams, NGX_YTD_API_DEFAULT_STANDARD_PARAMS } from 'ngx-ytd-api/common';
import { NgxYtdApiCommentsService } from './ytd-api-comments.service';
@NgModule({
imports: [
Expand All @@ -9,4 +9,20 @@ import { NgxYtdApiCommentsService } from './ytd-api-comments.service';
NgxYtdApiCommentsService
]
})
export class NgxYtdApiCommentsModule { }
export class NgxYtdApiCommentsModule {
/**
* Returns the module with the specified standard parameters
* @param defaultParams The default standard parameters
* @returns The module with the specified standard parameters
*/
static forRoot(
defaultParams: NgxYtdApiStandardParams
): ModuleWithProviders {
return {
ngModule: NgxYtdApiCommentsModule,
providers: [
{ provide: NGX_YTD_API_DEFAULT_STANDARD_PARAMS, useValue: defaultParams }
]
};
}
}
22 changes: 19 additions & 3 deletions projects/ngx-ytd-api-lib/search/src/ytd-api-search.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NgModule } from '@angular/core';
import { NgxYtdApiCommonModule } from 'ngx-ytd-api/common';
import { ModuleWithProviders, NgModule } from '@angular/core';
import { NgxYtdApiCommonModule, NgxYtdApiStandardParams, NGX_YTD_API_DEFAULT_STANDARD_PARAMS } from 'ngx-ytd-api/common';
import { NgxYtdApiSearchService } from './ytd-api-search.service';

@NgModule({
Expand All @@ -10,4 +10,20 @@ import { NgxYtdApiSearchService } from './ytd-api-search.service';
NgxYtdApiSearchService
]
})
export class NgxYtdApiSearchModule { }
export class NgxYtdApiSearchModule {
/**
* Returns the module with the specified standard parameters
* @param defaultParams The default standard parameters
* @returns The module with the specified standard parameters
*/
static forRoot(
defaultParams: NgxYtdApiStandardParams
): ModuleWithProviders {
return {
ngModule: NgxYtdApiSearchModule,
providers: [
{ provide: NGX_YTD_API_DEFAULT_STANDARD_PARAMS, useValue: defaultParams }
]
};
}
}
22 changes: 19 additions & 3 deletions projects/ngx-ytd-api-lib/videos/src/ytd-api-videos.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NgModule } from '@angular/core';
import { NgxYtdApiCommonModule } from 'ngx-ytd-api/common';
import { ModuleWithProviders, NgModule } from '@angular/core';
import { NgxYtdApiCommonModule, NgxYtdApiStandardParams, NGX_YTD_API_DEFAULT_STANDARD_PARAMS } from 'ngx-ytd-api/common';
import { NgxYtdApiVideosService } from './ytd-api-videos.service';

@NgModule({
Expand All @@ -10,4 +10,20 @@ import { NgxYtdApiVideosService } from './ytd-api-videos.service';
NgxYtdApiVideosService
]
})
export class NgxYtdApiVideosModule { }
export class NgxYtdApiVideosModule {
/**
* Returns the module with the specified standard parameters
* @param defaultParams The default standard parameters
* @returns The module with the specified standard parameters
*/
static forRoot(
defaultParams: NgxYtdApiStandardParams
): ModuleWithProviders {
return {
ngModule: NgxYtdApiVideosModule,
providers: [
{ provide: NGX_YTD_API_DEFAULT_STANDARD_PARAMS, useValue: defaultParams }
]
};
}
}

0 comments on commit e9e1704

Please sign in to comment.