If I have an app that uses lazy loading, and also using ngrx to manage state, I have a state instance for each feature with its own reducers, actions, etc. So for example:
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
With this structure, my main question is can the state between product-feature
municate and use the state between customer-feature
? If I, as a user, go to customer-feature
, but the customer-feature
needed some state information from the product-feature
, would it still render and get the data even though the product-feature
was never created because the user did not go to it (via lazy loading)?
Most examples I see online deal with ngrx as one AppState
and don't do lazy loading, and the lazy loading examples I see that do munication between ponents are parent/child. Some articles I read say that you need to extend the app state to include the feature state, as the feature state cannot be referenced in the app state. The instance I am wondering is municating state between sibling features. Is this possible with ngrx via lazy loading?
Thanks.
If I have an app that uses lazy loading, and also using ngrx to manage state, I have a state instance for each feature with its own reducers, actions, etc. So for example:
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
With this structure, my main question is can the state between product-feature
municate and use the state between customer-feature
? If I, as a user, go to customer-feature
, but the customer-feature
needed some state information from the product-feature
, would it still render and get the data even though the product-feature
was never created because the user did not go to it (via lazy loading)?
Most examples I see online deal with ngrx as one AppState
and don't do lazy loading, and the lazy loading examples I see that do munication between ponents are parent/child. Some articles I read say that you need to extend the app state to include the feature state, as the feature state cannot be referenced in the app state. The instance I am wondering is municating state between sibling features. Is this possible with ngrx via lazy loading?
Thanks.
Share Improve this question asked Aug 2, 2018 at 20:54 J-manJ-man 1,8333 gold badges30 silver badges52 bronze badges1 Answer
Reset to default 7ngrx will merge the new state of the lazy loaded module with the current state, and that will happen only when you navigate to one of the routes of your lazy loaded module, so if your product-feature is not loaded, you will not have access to it's store.
i suggest to move the part you need in your customer-feature, or you can create a shared module for that