N
N
Newbie Ivanovich2019-10-02 11:12:11
React Native
Newbie Ivanovich, 2019-10-02 11:12:11

How to make data loading in the background in react-native + expo?

You need to constantly load data and display it on the screen.
now the data is simply loaded into componentDidmount and if the data on the server has changed, you need to click on the button.
you need to add automatic data loading and make the component rerender.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Alexandrovich, 2019-10-02
@NovichokIvanovich

you have several options
1 is to do date push. Send keys to your phone by which you will understand what you need to catch or just update everything.
2 is to pull the request when moving, for example, to another screen and minimize the deployment of the application. This request should send the time of the last request to the server. On the server, you need to compare the time of the last request, and the current time, and if changes have occurred during this time, then return the keys by which you need to update part of the application, or completely. This approach has already been implemented and it works.
You may ask why not hang up some background worker that will time out to request changes - the main problem is that after a certain time, the OS simply stops your application.

D
Dimka Reactive, 2019-10-02
@raoffonom

This is implemented on websockets.
More about it here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question