Skip to content

Commit

Permalink
docs(useDelay): add info about delay's and uniqueDelay's times being …
Browse files Browse the repository at this point in the history
…stacked
  • Loading branch information
meszaros-lajos-gyorgy committed May 16, 2024
1 parent 9a4460e commit 57a30d6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/scripting/hooks/useDelay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export const useDelay = () => {
/**
* creates a timer with a unique identifier (TIMERdelay16)
* can be cancelled
*
* delay calls are stacked on top of previous values of delay() and uniqueDelay() calls:
*
* delay(100) ... -> executed 100 milliseconds after script start
* delay(200) ... -> executed (100 + 200) milliseconds after script start
*/
const delay = (delayInMs: number = 0) => {
delayOffset += Math.floor(delayInMs)
Expand All @@ -55,6 +60,11 @@ export const useDelay = () => {
* creates a timer without any identifier (TIMER)
* so the delay stays unique at runtime
* and consequently being uncancellable with the off method
*
* uniqueDelay calls are stacked on top of previous values of delay() and uniqueDelay() calls:
*
* uniqueDelay(100) ... -> executed 100 milliseconds after script start
* uniqueDelay(200) ... -> executed (100 + 200) milliseconds after script start
*/
const uniqueDelay = (delayInMs: number = 0) => {
delayOffset += Math.floor(delayInMs)
Expand Down

0 comments on commit 57a30d6

Please sign in to comment.