diff options
author | Regis <boudinot.regis@yahoo.com> | 2016-12-29 17:27:18 -0700 |
---|---|---|
committer | Regis <boudinot.regis@yahoo.com> | 2016-12-29 17:27:18 -0700 |
commit | 520e27d1a5d51aec07cdf962291440cb71c0afb9 (patch) | |
tree | 8d96a49dcc9c9206c092e8fca62fe6202f0be00d /app/assets/javascripts/vue_realtime_listener | |
parent | 7be5c2312eacf6028a2d8557ee7ac6e530724a39 (diff) | |
download | gitlab-ce-520e27d1a5d51aec07cdf962291440cb71c0afb9.tar.gz |
add vue_realtime_listener function
Diffstat (limited to 'app/assets/javascripts/vue_realtime_listener')
-rw-r--r-- | app/assets/javascripts/vue_realtime_listener/index.js.es6 | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/assets/javascripts/vue_realtime_listener/index.js.es6 b/app/assets/javascripts/vue_realtime_listener/index.js.es6 new file mode 100644 index 00000000000..72404c6f015 --- /dev/null +++ b/app/assets/javascripts/vue_realtime_listener/index.js.es6 @@ -0,0 +1,16 @@ +(() => { + gl.VueRealtimeListener = (removeIntervals, startIntervals) => { + const removeAll = () => { + removeIntervals(); + window.removeEventListener('beforeunload', removeIntervals); + window.removeEventListener('focus', startIntervals); + window.removeEventListener('blur', removeIntervals); + document.removeEventListener('page:fetch', removeAll); + }; + + window.addEventListener('beforeunload', removeIntervals); + window.addEventListener('focus', startIntervals); + window.addEventListener('blur', removeIntervals); + document.addEventListener('page:fetch', removeAll); + }; +})(window.gl || (window.gl = {})); |