S
SolidJS9mo ago
gsoutz

How can I protect nothing ever breaks, while the setTimeout is waiting

tsx
createEffect(() => {
if (puzzle_lala().is_revealed && is_jump_to_next_puzzle_immediately()) {

setTimeout(() => {
on_next_puzzle()
}, 600)
}
})
tsx
createEffect(() => {
if (puzzle_lala().is_revealed && is_jump_to_next_puzzle_immediately()) {

setTimeout(() => {
on_next_puzzle()
}, 600)
}
})
And Yes, I don't want to check whether this has been triggered everywhere else.
1 Reply
JCM
JCM9mo ago
Hard to guarantee that nothing ever breaks... A guess about a possible problem in your code snippet is that the effect can be re-executed before the timer expires, which will then call on_next_puzzle() twice. Usually you want to clean the timer in a onCleanup(() => clearTimeout(timerId))
Want results from more Discord servers?
Add your server