J-m*_*man 7 javascript lazy-loading ngrx angular
如果我有一个使用延迟加载的应用程序,并且还使用ngrx来管理状态,则每个功能的状态实例都有其自己的reducer,action等。因此,例如:
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
Run Code Online (Sandbox Code Playgroud)
通过这种结构,我的主要问题是之间的状态是否可以product-feature通信并使用之间的状态customer-feature?如果我作为用户进入customer-feature,但是customer-feature需要从中获取一些状态信息product-feature,即使product-feature由于用户没有去创建(由于延迟加载)而从未创建,它仍会渲染并获取数据吗?
我在网上看到的大多数示例都将ngrx视为一体,AppState并且不进行延迟加载,而在惰性加载示例中,组件之间的通信是父级/子级。我读过的一些文章说,您需要扩展应用程序状态以包括功能状态,因为无法在应用程序状态中引用功能状态。我想知道的实例正在兄弟功能之间传递状态。ngrx是否可以通过延迟加载来实现?
谢谢。
ngrx会将延迟加载的模块的新状态与当前状态合并,只有当您导航到延迟加载的模块的路由之一时,这种情况才会发生,因此,如果未加载产品功能,则您将无权访问到商店。
我建议在客户功能中移动所需的零件,或者您可以为此创建共享模块
| 归档时间: |
|
| 查看次数: |
1143 次 |
| 最近记录: |