S
soubok
I have to delay some function calls. Is it safe to store arguments
object and use it later ?
like this :
function DeferedCallDispatcher( dispatch ) {
var _eventList = {};
var _count = 0;
this.Dispatch = function() {
_eventList[++_count] = arguments;
}
this.Flush = function() {
if ( _count > 0 ) {
for ( var i in _eventList )
dispatch.apply( this, _eventList );
_eventList = {};
_count = 0;
}
}
}
object and use it later ?
like this :
function DeferedCallDispatcher( dispatch ) {
var _eventList = {};
var _count = 0;
this.Dispatch = function() {
_eventList[++_count] = arguments;
}
this.Flush = function() {
if ( _count > 0 ) {
for ( var i in _eventList )
dispatch.apply( this, _eventList );
_eventList = {};
_count = 0;
}
}
}