-1

I am using Gluon Connect to retrieve data from a REST service I built. I called the service from the mobile client when it wasn't running. What is the best approach to catch such a condition in the mobile code? I'd like to pop a dialog up for the user but wrapping the section where the RestClient is called doesn't seem to catch the network error. Perhaps its running on a different thread?

Thanks

1 Answers1

0

You can attach a listener to one of the properties of the GluonObservable that you get from the DataProvider:

GluonObservable gluonObservable = DataProvider.storeObject(obj, writer);

gluonObservable.exceptionProperty().addListener((obsValue, oldException,  newException) -> showDialog());

gluonObservable.stateProperty().addListener((obsValue, oldState, newState) -> {
                if (newState == ConnectState.FAILED) {
                    showDialog();
                }
            } );
jns
  • 6,017
  • 2
  • 23
  • 28