Waiting for connection to execute network requests. How should it be done?

Hello,

I am developing an ionic app for iOS and Android. The app use case sometimes may require that the app is used with a spotty or non-existing internet connection. I have some API calls which are done in the app. I am trying to make this app work even with non-optimal internet conditions.

What I came up with is a way to save each critical request and then process it. If there is a normal connection everything should behave normally, however if the connection is spotty, I’m thinking of saving the requests to some kind of local storage and running them periodically until they are done. Since I’m using angular’s HttpClient I get observables which are then consumed, the problem is how to handle the data which is returned from the requests after they finish if they are deferred in this “request queue” I’m building.

I am open to other solutions to the problem at hand. Thank you very much :slight_smile:

That seems like a very reasonable approach.

That’s hard to answer in the abstract, as it really depends on what these requests are doing. When I’ve done something similar, the app was primarily writing, not reading, so all I had to do was make a “backlog status” page showing how much stuff was in the backlog, giving the user the option to try to clear it out now, &c.

A backlog of reads would initially seem more complicated.