Angular 6 中延迟加载的特性能否在特性与 ngrx 之间传递状态?
Can lazy loaded features communicate state between features with ngrx in Angular 6?
如果我有一个应用程序使用 延迟加载,并且还使用 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
处理,不做懒加载,我看到的做组件间通信的懒加载例子是parent/child。我读过的一些文章说您需要扩展应用程序状态以包含功能状态,因为无法在应用程序状态中引用功能状态。我想知道的实例是兄弟功能之间的通信状态。 ngrx 可以通过延迟加载实现吗?
谢谢。
ngrx 会将延迟加载模块的新状态与当前状态合并,这只会在您导航到延迟加载模块的其中一个路径时发生,因此如果您的产品功能未加载,您将无法访问它的商店。
我建议在客户功能中移动您需要的部分,或者您可以为该部分创建一个共享模块
如果我有一个应用程序使用 延迟加载,并且还使用 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
处理,不做懒加载,我看到的做组件间通信的懒加载例子是parent/child。我读过的一些文章说您需要扩展应用程序状态以包含功能状态,因为无法在应用程序状态中引用功能状态。我想知道的实例是兄弟功能之间的通信状态。 ngrx 可以通过延迟加载实现吗?
谢谢。
ngrx 会将延迟加载模块的新状态与当前状态合并,这只会在您导航到延迟加载模块的其中一个路径时发生,因此如果您的产品功能未加载,您将无法访问它的商店。
我建议在客户功能中移动您需要的部分,或者您可以为该部分创建一个共享模块