Skip to content

Commit 9c8ef07

Browse files
author
Pooya Parsa
committed
[playground] debounce runs to 500ms
1 parent 0e24941 commit 9c8ef07

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

docs/pages/play.vue

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,20 @@
1313
<br>
1414
Please refer to
1515

16+
17+
18+
19+
20+
1621
<router-link to="/docs">Documentation</router-link>
1722
for more info about available tags.
1823

1924

25+
26+
27+
28+
29+
2030
</div>
2131
<div class="col-md-1">
2232
<form method='post' action='https://jsfiddle.net/api/post/library/pure/'
@@ -114,6 +124,7 @@
114124
import Vue from 'vue/dist/vue.common';
115125
import layout from '../layouts/site.vue';
116126
import * as Components from '../../components';
127+
import {debounce} from 'lodash';
117128
118129
const exampleHTML = `
119130
<b-progress v-model="counter" variant="success" :precision="1"
@@ -149,7 +160,8 @@
149160
originalWarn: null,
150161
originalError: null,
151162
vertical: false,
152-
full: false
163+
full: false,
164+
lazy_run_: null,
153165
};
154166
},
155167
head() {
@@ -159,10 +171,10 @@
159171
},
160172
watch: {
161173
html() {
162-
this.run();
174+
this.lazy_run();
163175
},
164176
js() {
165-
this.run();
177+
this.lazy_run();
166178
}
167179
},
168180
mounted() {
@@ -225,6 +237,12 @@ window.onload = function () {
225237
<div id='app'>
226238
${this.html}
227239
</div>`.trim();
240+
},
241+
lazy_run() {
242+
if (!this.lazy_run_) {
243+
this.lazy_run_ = debounce(this.run.bind(this), 500);
244+
}
245+
return this.lazy_run_;
228246
}
229247
},
230248
methods: {
@@ -252,7 +270,7 @@ window.onload = function () {
252270
253271
text = text.replace('[Vue warn]: ', '');
254272
255-
if(this.messages.length > 10) {
273+
if (this.messages.length > 10) {
256274
this.messages.splice(10);
257275
}
258276

0 commit comments

Comments
 (0)