SAP-Spartacus - 自定义事件重新加载触发问题
我创建了自定义事件:
export class DistributorSetEvent extends CxEvent {
/**
* Event's type
*/
static readonly type = 'DistributorSetEvent';
distributorName!: string;
}
事件生成器:
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$);
}
}
我将此配置保留在分发者模块文件中:
backend: {
loadingScopes: {
product: {
details: {
reloadOn: [DistributorSetEvent]
},
},
},
}
我在事件更改时保留了此调度:
this.eventService.dispatch(new CustomSiteContextActions.SetActiveDistributor(selectedValue),
);
错误:
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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论