-1

I am a BE dev and now I'm learning Angular 6. I'm really interested in State management using NGXS. I have several concerns with an example below:

I have an endpoint which return a set, about 16-20k records, of Accounts. This endpoint will be called when user opens the app and logs in successfully on browser. The returned data will be saved in store and it can be used in the whole life cycle of the application.

By storing the data in store, this list can be shared between components in the app, including: filter and search by account, update account information, etc.

Also, we can reduce the number of api call to filter the result (maybe there is a better approach here, please correct me!), and this would improve the UI/UX of the application.

My questions are:

  1. is it the right place to call endpoint to get and save such a large amount of data to store at beginning?

  2. will storing a large amount of data in store improve performance of the application?

  3. I think it's not really good approach to get all 16-20k accounts for this purpose, is there any better way to do?

  4. security problem: will storing account in store be easy to be exploited?

Trung Bún
  • 1,117
  • 5
  • 22
  • 47

2 Answers2

2
  • Tung's answer is the good one.
  • It is not related to state management here.
  • Calling API one times when user open the app can reduce the number of API calls. But This method is not good for app's performance. For example, When you access the page using the Select with the options are list of accounts mentioned above. Its very bad if you still call API without focusing or searching on Select.
Saarick
  • 21
  • 3
1
  1. You shouldn't call an API to get large amount of data at the beginning. It takes a lot of time to make your website ready to use and not good for UX.

  2. It will be faster for searching, filtering actions but the loading time at the beginning is really a problem.

  3. Store 16-20k records in front-end is not a good approach because your accounts data is changing overtime and you need to refresh it every time your database is updated.

  4. Yes. Storage in browser client is unsafe for sensitive data.

My suggestion:

  • Providing API for filtering and searching with pagination in the Back-end side, using db index or secondary storage like Elasticsearch for increasing searching performance.
  • Using http request for get searching result from backend
Stephen
  • 31
  • 2
  • currently we use pure spring jpa with specifications, performance is pretty good. The only problem is that this approach call endpoint too many times. we want to improve and btw, account details aren't changed that much :D – Trung Bún Aug 25 '20 at 08:58