BigW Consortium Gitlab

Commit 49aecb60 by Regis

properly remove events and get rid of lingering interval loops

parent 30e7952a
......@@ -49,28 +49,20 @@
startTimeLoops();
const removeTimeIntervals = () => {
clearInterval(this.timeLoopInterval);
};
const startIntervalLoops = () => {
startTimeLoops();
};
const removeTimeIntervals = () => clearInterval(this.timeLoopInterval);
const startIntervalLoops = () => startTimeLoops();
const removeAll = () => {
removeTimeIntervals();
window.removeEventListener('beforeunload', removeTimeIntervals);
window.removeEventListener('focus', startIntervalLoops);
window.removeEventListener('blur', removeTimeIntervals);
// turbolinks event handler
document.removeEventListener('page:fetch', () => {});
document.removeEventListener('page:fetch', removeAll);
};
window.addEventListener('beforeunload', removeTimeIntervals);
window.addEventListener('focus', startIntervalLoops);
window.addEventListener('blur', removeTimeIntervals);
// turbolinks event handler
document.addEventListener('page:fetch', removeAll);
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment