Namespace: Functions:defer

Functions:defer

Methods

defer(func, delayopt, nullable) → {function}

Defer the execution of a function until the callstack is empty. This works identical to setTimeout(function(){}, 1);

Parameters:
Name Type Attributes Default Description
func function

the function to defer

delay Number <optional>
<nullable>
1

the delay to apply in milliseconds, 1 is a non-minifiable value to target the next tick, but you may define any millisecond value you want, to manually delay the function execution

Source:
Throws:

error if func is not a function or delay is no number > 0

Returns:
the deferred function; the deferred function returns the timer id, in case you want to cancel execution
Type
function
Example
defer(function(){ doOnNextTick(); })();
defer(function(){ doInTwoSeconds(); }, 2000)();