SHARE
TWEET

Untitled

a guest Aug 25th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @NgModule()
  2. export class AnalyticsModule {
  3.   private static readonly EVENTS_MAP_TOKEN = new InjectionToken<EventsMap[]>(
  4.     'eventsMap'
  5.   );
  6.   static readonly EVENTS_MAP: EventsMap = {};
  7.  
  8.   constructor(
  9.     @Inject(AnalyticsModule.EVENTS_MAP_TOKEN) eventsMaps: EventsMap[][]
  10.   ) {
  11.     eventsMaps.forEach(events => {
  12.       Object.assign(AnalyticsModule.EVENTS_MAP, ...events);
  13.     });
  14.   }
  15.  
  16.   static forEventsMap(eventsMap: () => EventsMap): ModuleWithProviders {
  17.     return {
  18.       ngModule: AnalyticsModule,
  19.       providers: [{
  20.         provide: AnalyticsModule.EVENTS_MAP_TOKEN,
  21.         multi: true,
  22.         useFactory: eventsMap
  23.       }]
  24.     };
  25.   }
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top