Skip to content

Instantly share code, notes, and snippets.

@Sawtaytoes
Created May 3, 2019 06:25
Show Gist options
  • Save Sawtaytoes/e9de9408384694370e61d0caf3603a2b to your computer and use it in GitHub Desktop.
Save Sawtaytoes/e9de9408384694370e61d0caf3603a2b to your computer and use it in GitHub Desktop.
let previousColor
let previousValue
let timeoutId
const queueUpdate = () => {
if (
previousColor === color
&& previousValue === value
) {
return
}
$$invalidate('previousColor', previousColor = color)
$$invalidate('previousValue', previousValue = value)
clearTimeout(timeoutId)
$$invalidate('timeoutId', timeoutId = (
setTimeout(
() => addToQueue(id),
getRandomTimeout(),
)
))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment