先钻研规范的 effect 为何能够被 call 到:在 ProductReviewsEffects 构造函数里设置断点:

发现在拜访首页时,断点即触发。

为什么 AppModule 启动时,就要加载 ProductReviewEffect?

单击 AppModule,就跳转到我自定义的 AppModule 文件了,然而该文件里并没有 ProductReviewEffect:

这个 EffectFeatureModule 是规范框架的实现:

Spartacus 所有规范的 Effects 实例,都是在下列代码 ngrx-effects.js 里实例化的:

function createEffects(injector, effectGroups, userProvidedEffectGroups) {    /** @type {?} */    const mergedEffects = [];    for (let effectGroup of effectGroups) {        mergedEffects.push(...effectGroup);    }    for (let userProvidedEffectGroup of userProvidedEffectGroups) {        mergedEffects.push(...userProvidedEffectGroup);    }    return createEffectInstances(injector, mergedEffects);}

问题就是,对于 AppModule 而言,这些 Effects 是从哪里解析进去的?

看一下规范的 Effects 是怎么做的?

export const effects: any[] = [  ProductsSearchEffects,  ProductEffects,  ProductReviewsEffects,  ProductReferencesEffects,];EffectsModule.forFeature(effects),

解决方案

最初,失效了:

更多Jerry的原创文章,尽在:"汪子熙":