I am using react-apollo and creating an app that needs to sync the entire local data store of the application once every X seconds.
So essentially, imagine <input1 />
and <input2 />
both need to be synced to the server periodically.
<App>
<input1 />
<input2 />
</App>
The "Apollo Way" would be to let the inputs be like React bound inputs, but the binding would happen via query and mutations, with optimistic responses added to improve interactivity.
Create mutations for each input, and call these when the inputs change. Provide optimistic responses so that user actions take hold immediately.
Likewise, create a query to get the input values, and use these to initialize the inputs.
If others can change the inputs as well, you will need to set up a subscription.
I suggest you add a subscription to the whole app. It could work like this:
<input1 /><input2 />
subscribeToMore
function of the query. <input1 /><input2 />
dataIdFromObject
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.