Skip to content

Commit b6a67d1

Browse files
committed
📘 doc: adjust debounce value
1 parent 9eeabc1 commit b6a67d1

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

docs/components/xiao/playground/monaco.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ export const createEditor = async ({
211211
?.getValue()
212212

213213
if (value !== undefined) onChange(value)
214-
}, 200) as any as number
214+
// 1 / (average dev wpm * average English characters in a word / 60 secs in min) + single frame delay of 1/120
215+
// 1 / (60 * 4.79 / 60) + 0.08
216+
}, 288) as any as number
215217
})
216218

217219
// const parent = placeholder.parentElement!

docs/components/xiao/playground/playground.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,30 +118,38 @@ onUnmounted(() => {
118118
119119
const run = () => store.run()
120120
121+
// This doesn't need a high debounce
122+
// The editor itself already debounced the input
123+
// Just a single frame of 1/120 to avoid accidental
124+
// state sync if infinite loops occurs
125+
// so it doesn't freeze the tab
121126
watchDebounced(
122127
() => store.code,
123128
() => {
124129
store.run({ test: true })
125130
},
126131
{
127-
debounce: 300
132+
debounce: 8
128133
}
129134
)
135+
130136
watch(() => store.input.method, run)
131137
watchDebounced(() => store.input.path, run, {
132138
debounce: 300
133139
})
134140
watchDebounced(() => store.input.body, run, {
141+
// Preview is hidden between body editor
142+
// High debounce is ok since user can't see the result immediately
135143
debounce: 500
136144
})
137145
138146
// headers and cookie are already debounced by table editor
139147
watchDebounced(() => store.input.headers, run, {
140-
debounce: 10,
148+
debounce: 8,
141149
deep: true
142150
})
143151
watchDebounced(() => store.input.cookie, run, {
144-
debounce: 10,
152+
debounce: 8,
145153
deep: true
146154
})
147155
</script>

0 commit comments

Comments
 (0)