21
Views
6
Comments
Solved
How to start end stop setInverval in diferent actions?
Application Type
Reactive

Hi i'm having some dificult to stop a timer in a diferent action, 

actually i have this:

Starter action:

saving object:

In other action:

the Variable temporizador is Object Type.

Thanks for your sugestions.

Solution

and camelCase :)

clearInterval, setInterval

Hi @Pedro Rocha ,

2 things : i think the identifier of the interval is just an integer, not an object.

There is a typo : you have ClearInteval instead of ClearInterval, so letter 'r' is missing.

Dorine

Solution

and camelCase :)

clearInterval, setInterval

It was just this 2 erros... sometimes the simple makes it hard :/

I think you can avoid some extra code. Just remove output parameter from js, and use global unique variable for your timer.

Example:

window.my_fance_interval_id = setInterval( function() { /* do some work*/} );

wherever you need to stop it:

if (window.my_fance_interval_id !== undefined) { clearInterval(window.my_fance_interval_id); }

And I can see you are using actions inside your interval, so do not forget to stop it in OnDestroy event, otherwise you will get js errors complaining you are trying to execute a code that no longer exists.

Hi Pedro,

You can also use the Timing Events forge component. This contains the setInterval function and is configurable when it is active or not.

Hope this helps,

Vincent

I will explore it, Thanks!!

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