-
|
Hey Elgato, What is the recommended way to setup a timer (e.g. a stopwatch or countdown) through the modern node Typescript SDK? I found this old Archived example but it appears to use an older version of the SDK: https://github.com/elgatosf/streamdeck-timerfix, so not sure if that still is the recommended approach. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi @h0uter, The example you provided was necessary to fix an issue with the older version of the plugin environment, whereby plugins were effectively "background tabs" running on chromium inside of the Qt WebEngine, which made timers not work consistently. With the Node.js environment setInterval and clearInterval should work as expected out of the box. The first parameter is the code you want to run and the second parameter is time in milliseconds. Here is a small example where it prints the seconds for 10 seconds: let seconds = 0;
const interval = setInterval(() => {
seconds++;
streamDeck.logger.info(`Second ${seconds}`);
if (counter >= 10) {
clearInterval(interval);
streamDeck.logger.info('Done!');
}
}, 1000);The key here is to remember to call You can take a look at our Random Cat sample plugin for a more complete example. More specifically random-cat.ts Hope this helps! |
Beta Was this translation helpful? Give feedback.
Hi @h0uter,
The example you provided was necessary to fix an issue with the older version of the plugin environment, whereby plugins were effectively "background tabs" running on chromium inside of the Qt WebEngine, which made timers not work consistently.
With the Node.js environment setInterval and clearInterval should work as expected out of the box.
The first parameter is the code you want to run and the second parameter is time in milliseconds. Here is a small example where it prints the seconds for 10 seconds: