Core Docs | Additional Modules Docs
@Description: This constructor creates an object that fires a function on a timeout. The function can be swicthed out at any point before the delay reaches the fires by resetting the .func property of your instance
@File: functions/fireAfterDelay.js
@Param: Object params An object with the following properties, you must set either the seconds of milliseconds property
seconds - the number of seconds to wait before firing
milliseconds - the number of milliseconds to wait before firing
func - the function to fire after the delay
args - an array of arguments that get passed to the function when it fires
@Example:var myWaiting= new sb.fireAfterDelay({
func : function(){
alert('hello');
},
seconds : 2
});
@Description: Stops a sb.delayedFiring object instance from firing if exexuted before the delay has expired.
@File: functions/fireAfterDelay.js
@Example:var myWaiting= new sb.fireAfterDelay({
func : function(){
alert('hello');
},
seconds : 2
});
//if this is executed before the 2 seconds are up, then the dealyed firing is aborted
myWaiting.abort();
@Description: Fires a function after waiting the specified number of seconds or milliseconds. You can run this on any function if globals are not disabled. If they are you would need to use the call method demostrated below.
@File: functions/fireAfterDelay.js
@Return: Object A sb.fireAfterDelay instance which has an abort() method
@Example://with globals on
function hello(){
alert('hello');
}
//fires the function after 10 seconds
var myEvent = hello.fireAfterDelay({seconds : 10});
//this would abort the event before it ran if executed before the ten seconds were up
myEvent.abort();
//with globals off
sb.functions.fireAfterDelay.call(hello,1);
@Description: Fires a function repeatedly on a timeout expressed in milliseconds or seconds
@File: functions/fireRepeatedly.js
@Param: Object o Timeout can be in either seconds or milliseconds
milliseconds - the time between firing in milliseconds
seconds - The time between firing in seconds
@Return: Object Returns an object that has a stop method to end the repeated firing
@Example:sb.functions.fireRepeatedly.call(hello,1);
@Description: You can pass it any number of functions as arrays and the one that works with return
@File: functions/keepTrying.js
@Author: Paul Visco
@Version: 1.0 11/19/07
@Param: Any number of functions, can be either function references or inline anonymous functions
@Return: returns the return value of the first funciton that returns true
@Example:var x = sb.utils.keepTrying(function1, function2, function3);