在效果初始化之前效果尝试 运行

Effect trying to run before effects initialised

我的 ngrx 设置有问题,因为效果试图 运行 在效果初始化之前。

我的 Redux 工具如下所示:

如你所见,我的[Auth] Create Auth试图在@ngrx/effects/init之前运行,所以效果不是运行ning。

如何确保在 executed/subscribed 任何效果之前初始化效果?

使用 OnInitEffects 钩子:

Implement this interface to dispatch a custom action after the effect has been added. You can listen to this action in the rest of the application to execute something after the effect is registered.

class UserEffects implements OnInitEffects {
  ngrxOnInitEffects(): Action {
    return { type: '[UserEffects]: Init' };
  }
}

docs