Question

While using FLUX in a CRUD application, according to what I understood, initially the data is returned from an AJAX call and then stored in the STORE. So, all the data that is currently viewed is only from the STORE.

So my question is, if I'm seeing a listing page of all the data and some other user changes that data in the server, wouldn't I have to use an AJAX call again to list all the data and then again store in the STORE? What would be the point of using STORE if I have to call again?

I saw a tutorial where initially on the page load, the data gets rendered and after that everything is done with the data in the STORE. But with this, if the server data changes by some other users, wouldn't I have to fully reload the page again? I seem to have a lot of confusion regarding this issue.

What is the use of FLUX and how is it implemented? Also, what is the correct way of implementing it in a CRUD application?

Was it helpful?

Solution

There are actually two questions in the question. The first one is how Flux architecture is connected with the backend?

Good diagram is given in this blog post. You need CRUD API as depicted to talk to backend (on the left). You situation may be more subtle, but it was not reflected in the question. In another article variations, deviating from basic Flux, are given and discussed.

The second question is not specific for Flux. It's about resolving editing conflicts. This part of the question can not be answered without knowing the logic of your application. In any case, if you design your API well (see, for example, "REST API Design Rulebook" by Mark Masse), basing it on REST principles, the CRUD logic and conflict resolution will need to be made explicit in the API design process.

Depending on how timely the information should be, it is possible to utilize websockets, which will inform all interested client on changes in the data (this makes the implementation more complex and demanding, but inevitable for some applications like games and trading).

Licensed under: CC-BY-SA with attribution
scroll top