0
votes

Recently made a component with state management using NGRX entity, where previously we have used straight up NGRX action->reducer->effect->selector.

From first impressions it seems to me that the design pattern expects you to load the total record set from your model into state, so thats what i did. Then I got thinking, what happens when this model starts to contain a lot of data.

So the question is, does entity make sense if you are only going to load a subset of data into state?

For example, if I load only a subset, then sorting a column in table of that data doesn't work (as a user would expect) when implemented as an action on the store.

1
Maybe some actions should operate on the store and some should make api calls? - ldgorman

1 Answers

-1
votes

I'm not sure if I got your question, but will try to answer anyway.

  1. It does make sense to add ngrx entities to your reducer, when:
    • you are able to find unique identy for each entity in your state
    • end user actions will cause adding new entities to your state, updating or deleting existing entities

So if there is high probability that your entites will be inserted/updated/deleted - ngrx entities are the way to go.

  1. It does not make sense to add ngrx entities to your reducer, when:
    • the entieties that you are storing won't be ever updated. This is overengineering really, plain array will do the trick here.