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?
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?