Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 10, 2023
1 parent 07ab829 commit be3f72b
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
if (!window.SharedWorker) {
console.debug('😭 django-browser-reload cannot work in this browser.')
} else {
function debounce(func, timeout = 300){
let timer;
function debounce (func, timeout = 300) {
let timer
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => { func.apply(this, args); }, timeout);
};
clearTimeout(timer)
timer = setTimeout(() => { func.apply(this, args) }, timeout)
}
}
const worker = new SharedWorker(workerScriptPath, {
name: 'django-browser-reload'
})

worker.port.addEventListener('message', (event) => {
if (event.data === 'Reload') {
debounce(() => location.reload());
debounce(() => location.reload())
}
})

Expand Down

0 comments on commit be3f72b

Please sign in to comment.