Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2018-07-16 15:34:46 +0300
committerFatih Acet <acetfatih@gmail.com>2018-07-18 13:55:57 +0300
commit01aa7752ef9b6bac2f9fbcf912ab4fc87c0075f1 (patch)
treee61d713da5f14ff57896e4962ddd105d9b0469b6 /app/assets/javascripts/autosave.js
parentef2b2546eaae74347b0ae54b15270c50daecbc5f (diff)
Debounce Autosave callback.
Diffstat (limited to 'app/assets/javascripts/autosave.js')
-rw-r--r--app/assets/javascripts/autosave.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/assets/javascripts/autosave.js b/app/assets/javascripts/autosave.js
index e8c59fab609..eca84ce16ce 100644
--- a/app/assets/javascripts/autosave.js
+++ b/app/assets/javascripts/autosave.js
@@ -1,5 +1,6 @@
/* eslint-disable no-param-reassign, prefer-template, no-void, consistent-return */
+import _ from 'underscore';
import AccessorUtilities from './lib/utils/accessor';
export default class Autosave {
@@ -13,7 +14,13 @@ export default class Autosave {
this.key = 'autosave/' + key;
this.field.data('autosave', this);
this.restore();
- this.field.on('input', () => this.save());
+ this.field.on('input', this.debounceInputHandler());
+ }
+
+ debounceInputHandler() {
+ return _.debounce(() => {
+ this.save();
+ }, Autosave.DEBOUNCE_TIMER);
}
restore() {
@@ -57,4 +64,6 @@ export default class Autosave {
dispose() {
this.field.off('input');
}
+
+ static DEBOUNCE_TIMER = 300;
}