lib/common/src/notifications/notification.module.ts
Static forChild | ||||||||
forChild(notificationConfigs: NotificationConfig[])
|
||||||||
Parameters :
Returns :
ModuleWithProviders<NotificationModule>
|
import {
NgModule,
ModuleWithProviders,
Optional,
SkipSelf
} from '@angular/core'
import {
NOTIFICATION_COUNTERS,
NotificationConfig,
NotificationService
} from './notification.service'
import {
TranslationsModule
} from '../translations'
import en from './i18n/en.json'
import de from './i18n/de.json'
@NgModule({
imports:[
TranslationsModule.forChild("NOTIFICATIONS", {en, de}),
],
providers: [
NotificationService,
]
})
export class NotificationModule {
static forChild(notificationConfigs: NotificationConfig[] = []): ModuleWithProviders<NotificationModule> {
return {
ngModule: NotificationModule,
providers: [
...notificationConfigs.map( notificationConfig => ({
provide: NOTIFICATION_COUNTERS,
multi: true,
deps: notificationConfig.deps,
useFactory: notificationConfig.factory
}))
]
}
}
}