233
Views
4
Comments
Solved
When use setInterval() How many errors will you receive if you will not destroy it
Application Type
Mobile, Reactive

Hi, 

I get some errors when use " setInterval( )" ...
How many errors will you receive if you will not destroy setinterval(). ?

Also, can you tell me some good tips/concerning about JS usage in Outsystems? 
I know that the first rule in Outsystems about JavaScript is, try to don't use JavaScript xD!!

2023-04-16 15-25-31
Krishnanand Pathak
Solution

Hi @Samuel Frade,

Error will occur every time based on the time specified in setInterval( ) parameter.  
You should clear the Interval by using clearInterval() as explained below.


Regards
Krishnanand Pathak

2018-10-29 08-31-03
João Marques
 
MVP
Solution

Hi Samuel,


When you set up listeners or asynchronous calls to be made, it is indeed important to remove them on the OnDestroy event of the screen, to be prevent them being triggered but no-handler-exists-to-process-them error occurring.

Regarding the usage of JavaScript, ideally you wouldn't need it, and you can take advantage of the platform existing actions to do your work faster but also more readable. However, there are some situations that you need to use JavaScript to extend your app further.

As good practices, I would recommend reading the Extend Your Mobile and Reactive Apps Using JavaScript documentation, use the JavaScript API as well as to explore what OutSystems UI offers out of the box before implementing yourself. For instance, functions like ScrollToElement or SetFocus, among others, are available out of the box, like in the image below:


Kind Regards,
João

2023-04-16 15-25-31
Krishnanand Pathak
Solution

Hi @Samuel Frade,

Error will occur every time based on the time specified in setInterval( ) parameter.  
You should clear the Interval by using clearInterval() as explained below.


Regards
Krishnanand Pathak

2018-10-29 08-31-03
João Marques
 
MVP
Solution

Hi Samuel,


When you set up listeners or asynchronous calls to be made, it is indeed important to remove them on the OnDestroy event of the screen, to be prevent them being triggered but no-handler-exists-to-process-them error occurring.

Regarding the usage of JavaScript, ideally you wouldn't need it, and you can take advantage of the platform existing actions to do your work faster but also more readable. However, there are some situations that you need to use JavaScript to extend your app further.

As good practices, I would recommend reading the Extend Your Mobile and Reactive Apps Using JavaScript documentation, use the JavaScript API as well as to explore what OutSystems UI offers out of the box before implementing yourself. For instance, functions like ScrollToElement or SetFocus, among others, are available out of the box, like in the image below:


Kind Regards,
João

2022-07-03 17-24-08
Sourabh sharma

Hi Samuel Frade

The setInterval() method calls a function at specified intervals (in milliseconds).

The setInterval() method continues calling the function until clearInterval() is called, or the window is closed.

[1 second = 1000 milliseconds.]

-----------------------------------------------------------

1. To clear an interval, use the id returned from setInterval():myInterval = setInterval(function, milliseconds);

2.Then you can to stop the execution by calling clearInterval():clearInterval(myInterval);


Hope this help you

2023-04-14 11-47-10
Samuel Frade

Thank you for these clarifications !

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