Mobile - exception thrown while changing screens and connection changes

Hi, 

I'm having an exception and a screen behaviour I can't really handle in this specific scenario.

I'm on a screen with a list, the list is synced on login. New items can be created Online and Offline.

If items are created offline, they are synced as soon as you get online, and that's working great.
Item detail is only available IF you are online or were created while offline and sync hasn't happened for those items yet. 


Now for the real pain:

I'm Online and everything is synced. Mobile data is disabled. Wireless is enabled and with and active Internet connection.

Now quickly disable the wireless connection and click "New".  

It navigates to the screen but throws a communication exception. I'm using the Getnetworkstatus() function in some parts of my code and it works well, but in this case it seem to not being fast enough detecting that change. I have (against my good practices will) removed the exception message but, since I'm loading a big binary (up to 2mb) I'm also using this component Progress Spinner to show an overlaying loading animation. It as a local var to control if the screen is loading or not. Once the exception is catched, context is loss and I can't return that var to the state where the loader shouldn't show. 

I've tryed everything I can remember, even changing to the list screen, but it get's stuck on redirections. 

I'm thinking about using another loader animation but that will just take me more time and testing since I'm not a JS expert. Also, even if I get another loader that doesn't locks my screen until I click back and repeat the operation, I still have that exception without a message...

I have also tryed using the webblock NetworkStatusChanged, but couldn't really understand it fully and there are no complete examples for it that apply to my case.

What can you suggest? 

Regards
Bruno

Hi Gilfoyle,

I had a bit of a problem with connection error messages polluting user experience when it wasn't really necessary. I found using the NetworkStatusChange block pretty helpful in cleaning it up.

usage (for me but yours may differ):  I dropped it onto each screen (but you could probably do it in the layout web block to cover more cases with less code.

  1. create a local boolean called "OnlineStatus" and set it to False (so you're starting out assuming no connection, so you don't start any server requests that could fail)
  2. Drop the NetworkStatusChanged (NSC) web block into the root of your page (or layout web block if you want to do it that way)
  3. map the NetworkStatusChanged (NSC) event to a new Screen Action.  All this does is assign the NSC IsOnline value to your local OnlineStatus value.  So if the NSC says IsOnine = True, your local boolean gets set to True and vice versa.
  4. add a conditional structure to your screen (or webblock to show relevant content to being online or not). so you might want to disable some buttons when the app is offline, you might want to put conditional logic into some of your screen actions.  generally, use the local OnlineStatus to inform your app if its safe to request stuff from the server.

and my NetworkStatusChanged screen action (haha, just noticed I didn't cleanup the auto generated name.  ignore that, its not important, just sloppy of me)

Thanks Steve. That's helpful! Will look at it soon. 


Regards
Bruno