Skip to content

Instantly share code, notes, and snippets.

@troutacular
Last active October 28, 2015 22:04
Show Gist options
  • Save troutacular/b0b79771d86ebb7c83af to your computer and use it in GitHub Desktop.
Save troutacular/b0b79771d86ebb7c83af to your computer and use it in GitHub Desktop.
JS: Multiple Timeouts
/**
* TimeOuts
* ========
*
* Use the functions below to handle mutliple timeouts
*
* New timeout
* timeOuts['ID'] = setTimeout(someFunction('values'), 250);
*
* Clear specific timeout
* clearTimeout(timeOuts['ID']);
*/
// array for all timeOuts
var timeOuts = [];
// clear all timeOuts
function clearTimeouts() {
'use strict';
for ( var key in timeOuts ) {
clearTimeout( timeOuts[key] );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment