You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ngrxEntityRelationshipReducer does update the other entity collections, but since @ngrx/data has already added the response from the server to the entity cache, the entity in the cache still contains the related entities that were in the server response.
So if we dispatch reduceGraph after @ngrx/data loads this user, the entities in entityCache will look like that:
Something to note, @ngrx/data does not automatically initialize the entityCache with empty collections. It starts like that:
{entityCache: {}}
So if we tell @ngrx/data to load a user entity then dispatch reduceGraph on the response, the store will look something like that:
{
entityCache: {
User: { ... }}}
The simplest way I found to deal with this is to just add empty arrays into all the entity collections when the app initializes. You can also see this in the stackblitz example.
The text was updated successfully, but these errors were encountered:
Problem
The ngrxEntityRelationshipReducer meta reducer does not work as expected when used along with @ngrx/data.
Here is a stackblitz project to illustrate the behavior:
stackblitz
For these examples say the backend returns that:
ngrxEntityRelationshipReducer does update the other entity collections, but since @ngrx/data has already added the response from the server to the entity cache, the entity in the cache still contains the related entities that were in the server response.
So if we dispatch reduceGraph after @ngrx/data loads this user, the entities in entityCache will look like that:
User
Company
Address
Worth Mentioning
Something to note, @ngrx/data does not automatically initialize the entityCache with empty collections. It starts like that:
So if we tell @ngrx/data to load a user entity then dispatch reduceGraph on the response, the store will look something like that:
The simplest way I found to deal with this is to just add empty arrays into all the entity collections when the app initializes. You can also see this in the stackblitz example.
The text was updated successfully, but these errors were encountered: