Skip to content

Instantly share code, notes, and snippets.

@ycmjason
Created February 26, 2020 16:26
Show Gist options
  • Save ycmjason/f80e3a7960115f1ca7c0f8bca9f020b8 to your computer and use it in GitHub Desktop.
Save ycmjason/f80e3a7960115f1ca7c0f8bca9f020b8 to your computer and use it in GitHub Desktop.
const watch = (callback: () => any) => {
const watcher = {
callback: debounce(() => {
dependencies.clear()
callback()
watcher.dependencies = new Set(dependencies)
}, 0),
dependencies: new Set<symbol>(),
}
watcher.callback()
watchers.push(watcher)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment