Answer the question
In order to leave comments, you need to log in
How to organize the loading of data via api as needed?
Instrumental question from a newbie.
Suppose you need to write a large react application like some kind of CRM system.
The application will work with a lot of interconnected entities, let's consider a simple example of Client + Case.
The user opens a list of hits page in the browser, at this moment the application sends a request to the api, receives the list, puts it in the store, everything is as usual.
However, the payload of each hit in the api response contains only the userId of the hit author, so we need to additionally ask the api for information about the user(s).
But not every time to request the same users? It is necessary to put them in the store and, if necessary, see if they are there and if they are, take them from there, if not, ask.
But how do you know if a particular user has been requested before? How, in the absence of a user in the store, to understand that he was requested earlier, but such a user simply does not exist, so he is not in the store?
If the user visits the view page for a particular hit, the application must also understand whether to ask the api for a list of comments, comment authors, a list of categories, possible statuses, etc. The user may have previously visited pages with other hits and, probably, the categories have already loaded. Or not loaded and need to request them? There can be 100500 comments in the store, but how to understand if there are comments of the desired appeal? Have they been requested before?
Well, you understand.
My question is not about the architecture, it is not necessary to offer to store the history of previously loaded data somewhere. I already wrote such a bike. Maybe there are flexible and convenient tools for this?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question