Answer the question
In order to leave comments, you need to log in
Synchronization of the application with the database and with react.js?
Hello, I will try to describe the problem briefly.
Let's say there is an application in JS. There is a View for it (react + alt.js). And there is some kind of wrapper (CRUD) for working with the database (indexedDb + some kind of server base (not the point)).
I'll describe abstractly:
Let's say the application: a gun :) The user calls the shoot method, this method reduces the number of remaining cartridges by 1. I need to write it to the database right away. But let's say in the description of this method, you will not immediately call the CRUD object. and call update in the same place... You will have to do this in every method of the gun. How is it properly implemented?
Then the same method in the application should change the state flux and update the view...
Actually the question is: how to synchronize all this correctly, so that after a state change, all this is immediately written to the database? where to read about it? What architecture should be? What good literature do you recommend? Preferably on the principles themselves.
Answer the question
In order to leave comments, you need to log in
It all depends on the implementation.
As an example.
When you shoot You tell the server I shoot there then. And you forget about it.
The north is processing the message. If the number of cartridges has decreased. Sends you the status of your gun, how many ammo it has, etc.
You parse the packet from the server and update the state of your already. How you implement it is up to you.
There is another model when the logic is executed only on the client side. Those. you only tell the server your state, and the server believes you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question