0

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.

ldgorman
  • 1,553
  • 1
  • 14
  • 39

1 Answers1

-1

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.
Pawel Kiszka
  • 812
  • 7
  • 11
  • I'm sorry but this doesnt answer the question – ldgorman May 22 '19 at 08:40
  • May you clarify what the question is about? Any code example would help. I thought the part that describes question is quite clear for me: `So the question is, does entity make sense if you are only going to load a subset of data into state?` - but apparently its not. – Pawel Kiszka May 22 '19 at 16:26