Question about [set|clear]Timeout()

U

Ugo

Hi guys,

sorry, I couldn't write a better Subject :(

I'd like to allow multiple launch of a function with the delayed execution
that breaks the launch previously scheduled
All writing one only function :)

what I designed is this:

function action( )
{
function myAct( )
{
alert( 'hi' );
action.timerID = null;
}
if( action.timerID )
{
clearTimeout( action.timerID );
action.timerID = null;
}

action.timerID = setTimeout( myAct, 500 );
}

as you can see, I'm using a "static private" variable to save
the reference timeout, avoiding global variables and/or closures, but
I "close" myAct() which is the real action that is launched ( sooner or
later)

What say, is there an other way "nice" to make this thing?
I should think more OOP (so others told me...), but I do not know how?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top