'SAP- Spartacus - custom event reload trigger issue

I have created the custom event :

export class DistributorSetEvent extends CxEvent {
  /**
   * Event's type
   */
   static readonly type = 'DistributorSetEvent';
      distributorName!: string;
}

event builder:

 export class DpSiteContextEventBuilder {
    constructor(
      protected actionsSubject: ActionsSubject,
      protected eventService: EventService
    ) {
      this.register();
    }
  
    /**
     * Registers the site context events
     */
    protected register(): void {
      this.registerSetDistributor();
    }
  
    /**
     * Register the language set action
     */
    protected registerSetDistributor(): void {
      const DistributorEvent$ = this.actionsSubject.pipe(
        ofType<CustomSiteContextActions.SetActiveDistributor>(
          CustomSiteContextActions.SET_ACTIVE_DISTRIBUTOR
        ),
        map((languageAction) =>
          createFrom(DistributorSetEvent, {
            distributorName: languageAction.payload            
          })
        )
      );
     
  
      this.eventService.register(DistributorSetEvent, DistributorEvent$);
    }
}

I kept this config in the distributor module file:

backend: {
   loadingScopes: {
      product: {
         details: {
            reloadOn: [DistributorSetEvent]
         },         
      },
   },
}

I kept this dispatch in on event change:

this.eventService.dispatch(new CustomSiteContextActions.SetActiveDistributor(selectedValue),  
);

Error:

core.js:6498 ERROR TypeError: Cannot read properties of undefined (reading 'getEventMeta')
    at get (spartacus-core.js:4244:28)
    at Array.map (<anonymous>)
    at ProductLoadingService.getProductReloadTriggers (spartacus-core.js:21402:14)
    at ProductLoadingService.getProductForScope (spartacus-core.js:21373:62)
    at ProductLoadingService.initProductScopes (spartacus-core.js:21352:58)
    at ProductLoadingService.get (spartacus-core.js:21343:14)
    at ProductService.get (spartacus-core.js:21471:35)
    at SwitchMapSubscriber.project (spartacus-storefront.js:4086:39)
    at SwitchMapSubscriber._next (switchMap.js:28:1)
    at SwitchMapSubscriber.next (Subscriber.js:49:1)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source