74
Views
5
Comments
Solved
[OutSystems UI] block to call an event when intenet Connection changes
outsystems-ui
Reactive icon
Forge asset by OutSystems
Application Type
Mobile

Hi, I need a block that triggers an event when the internet status changes offline/online.

I´m Trying to use the Outsystems UI Block "NetworkStatusChanged" but when i test it and shutdown my connection, enters in loop, refreshing my offline screen and sending and exception "Request Failed with an error". 

This block was suposed to just trigger when the status change, as it says in description, but at my app, when is online everything is good, when is offline i cant understand what is happening. 

Here's the logic I implemented to handle the event:

the second if, is a boolean variable to control the flow.

Thanks for your help,

Pedro Rocha

2022-11-12 11-28-30
Gonçalo Martins
Staff
Solution

Hello @Pedro Rocha 

The issue is on the logic of your application and not on the NetworkStatusChanged block.

You caused an infinite loop by not initializing your local variable Online.

To prevent this, you do the following:

  • Add an OnInitialize event to initialize your OnlineLocal (no default value needed on the variable as well) variable:
  • Simplify your NetworkStatusChanged handler:

Hope it helps!

Cheers,
GM

NetworkConTest_Fixed.oml
2022-11-12 11-28-30
Gonçalo Martins
Staff

Hello @Pedro Rocha 

Can you please share an oml where we can reproduce the same use case, just to avoid back and forward conversations?

I just did a quick test and is working as intended:

Cheers,
GM

UserImage.jpg
Pedro Rocha

Hi Gonçalo,

Here is a simple app, with the loop. 

Thanks for your help,

Pedro Rocha

NetworkConTest.oml
2022-11-12 11-28-30
Gonçalo Martins
Staff
Solution

Hello @Pedro Rocha 

The issue is on the logic of your application and not on the NetworkStatusChanged block.

You caused an infinite loop by not initializing your local variable Online.

To prevent this, you do the following:

  • Add an OnInitialize event to initialize your OnlineLocal (no default value needed on the variable as well) variable:
  • Simplify your NetworkStatusChanged handler:

Hope it helps!

Cheers,
GM

NetworkConTest_Fixed.oml
UserImage.jpg
Pedro Rocha
2022-04-19 13-20-22
Andrea Lembo

Hi,

Try this component: Client Awaitable Popups - Offline (demo), the module expose an action WaitUntilOnline that block the flow until the network is available.

However, I've never test the component in a mobile scenario.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.