如果我有一个应用程序使用延迟加载,并且还使用ngrx 来管理状态,我为每个功能都有一个状态实例,它有自己的缩减器、操作、等等 例如:
product-feature
product-edit
product-add
product-admin
state
product.reducer.ts
product.actions.ts
product.effects.ts
product.index.ts
customer-feature
customer-edit
customer-add
customer-admin
state
customer.reducer.ts
customer.actions.ts
customer.effects.ts
customer.index.ts
有了这个结构,我的主要问题是product-feature
之间的状态是否可以通信和使用customer-feature
之间的状态?如果我作为用户转到 customer-feature
,但是 customer-feature
需要来自 product-feature
的一些状态信息,会它仍然呈现并获取数据,即使 product-feature
因为用户没有访问它(通过延迟加载)而从未创建?
我在网上看到的大多数示例都是将 ngrx 作为一个 AppState
来处理并且不进行延迟加载,而我看到的在组件之间进行通信的延迟加载示例是父/子。我读过的一些文章说您需要扩展应用程序状态以包含功能状态,因为无法在应用程序状态中引用功能状态。我想知道的实例是兄弟功能之间的通信状态。 ngrx 可以通过延迟加载实现吗?
谢谢。
最佳答案
ngrx 会将延迟加载模块的新状态与当前状态合并,只有当您导航到延迟加载模块的路由之一时才会发生这种情况,因此如果您的产品功能未加载,您将无法访问它的商店。
我建议在客户功能中移动您需要的部分,或者您可以为此创建一个共享模块
关于javascript - 延迟加载的特性可以在 Angular 6 中使用 ngrx 来传递特性之间的状态吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51662022/