summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_realtime_listener
diff options
context:
space:
mode:
authorRegis <boudinot.regis@yahoo.com>2016-12-29 17:27:18 -0700
committerRegis <boudinot.regis@yahoo.com>2016-12-29 17:27:18 -0700
commit520e27d1a5d51aec07cdf962291440cb71c0afb9 (patch)
tree8d96a49dcc9c9206c092e8fca62fe6202f0be00d /app/assets/javascripts/vue_realtime_listener
parent7be5c2312eacf6028a2d8557ee7ac6e530724a39 (diff)
downloadgitlab-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.es616
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 = {}));