0

Currently, my app requires an internet connection to operate and pull external API data, I will be adding some syncing/storage and perhaps a network check in the next version.

For now, I have been trying to add a timeout to the data loading pages (), as currently if there is no web connection within the app. The "Please Wait..." just keeps going round with no option to go back. You have to close the app.

I tried adding in a timeout with rxjs imports in the data pages with no joy. Any ideas?

import 'rxjs/add/operator/timeout';

.timeout(8000)

Ideally it would be nice to have a "No internet connection" prompt on Timeout.

Here are the relevant app files http://plnkr.co/edit/NgHH41zsFcfXDyRApAXx?p=catalogue

me9867
  • 1,519
  • 4
  • 25
  • 53
  • Does this example help: http://stackoverflow.com/questions/38990350/angular-2-rxjs-timeout-callback – DeborahK Apr 14 '17 at 21:01

1 Answers1

0

Make use of the catch operator after the http.get request.

If the request fails, as it will if there is no internet connection, then return an an empty product list to trigger the subscription and dismiss the loading controller.

unitario
  • 6,295
  • 4
  • 30
  • 43