Last active
December 20, 2021 11:45
-
-
Save krabs-github/1af5a566b6c2e764c009aa8a73da242f to your computer and use it in GitHub Desktop.
[JavaScript - Set Interval and Clear Interval for Stream Deck Template] JavaScript - Set Interval and Clear Intervals for Stream Deck Template #JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Declare globally | |
var vKrabs_Intervals = {}; | |
// Functions | |
let vKrabs_IntervalID = JSON.stringify(jsn.context); | |
function startInterval(func, time) { | |
vKrabs_Intervals[vKrabs_IntervalID] = setInterval(func, time); | |
} | |
function stopInterval() { | |
clearInterval(vKrabs_Intervals[vKrabs_IntervalID]); | |
} | |
if (vKrabs_Intervals[vKrabs_IntervalID]) { | |
stopInterval(); | |
startInterval(UpdateTwitchImage, 5000); // Change UpdateTwitchImage to the function you want to run in the interval | |
} else { | |
startInterval(UpdateTwitchImage, 5000); // Change UpdateTwitchImage to the function you want to run in the interval | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment