Issue
I am working on an Angular project which is using ngrx/store.
A component of mine needs data from the backend. So the flow usually is like this:
- dispatch
Action - invoke
Effect--> call backend - update
storewith data from backend - component uses
selectorto get the data
Now we have the case that our backend returns lots of data (e.g. 100.000) entries. For some reasons I can not do pagination.
I am currently thinking to NOT keep the 100.000 entries in the store since the data is not used anywhere else in the app (SHARI principle violated). Would you think this is a good idea:
- dispatch
Action - invoke
Effect--> call backend - component listens for
ApiCallSuccessActionand uses data from payload.
The benefit from my side would be: We always use Effects to call the backend (consistency).
What would you suggest? The alternative to me is that the component just calls the API and uses data directly.
Solution
Both options have pros and cons - and I think that it's your choice and your teams choice.
You can also take a look @ngrx/component-store which is a middle ground, and a good fit for state that is bound to the component's lifestyle.
Answered By - timdeschryver
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.