import { FactoryProvider , InjectionToken } from '@angular/core' ; import { IEntryComponent } from '../directives/entry-component.directive' ; export interface IEntryComponentsEntities { status : ( new ( ... args ) => IEntryComponent ) [ ] ; container : ( new ( ... args ) => IEntryComponent ) [ ] ; floating_menu : ( new ( ... args ) => IEntryComponent ) [ ] ; } export const ENTRY_COMPONENTS_ENTITIES = new InjectionToken ( 'ENTRY_COMPONENTS_ENTITIES' ) ; export const ENTRY_COMPONENTS_PROVIDER = new InjectionToken ( 'ENTRY_COMPONENTS_PROVIDER' ) ; param metadata export function provideEntryComponentsEntities ( metadata ) { return { provide : ENTRY_COMPONENTS_ENTITIES , useValue : metadata , multi : true } ; } export function entryComponentsProviderFactory ( entryComponentsEntities ) { return entryComponentsEntities . reduce ( ( prev , next ) => ( { container : [ ... prev . container , ... next . container ] , status : [ ... prev . status , ... next . status ] , floating_menu : [ ... prev . floating_menu , ... next . floating_menu ] } ) , { container : [ ] , status : [ ] , floating_menu : [ ] } ) ; } export const EntryComponentsProvider = { provide : ENTRY_COMPONENTS_PROVIDER , useFactory : entryComponentsProviderFactory , deps : [ ENTRY_COMPONENTS_ENTITIES ] } ;