From b46503a8a08a10fe23adb6882e0047685ec519d2 Mon Sep 17 00:00:00 2001 From: Brian Holmes Date: Fri, 5 Apr 2024 02:39:01 -0400 Subject: [PATCH] debounce yaml editor --- .../features/generic-yaml-editor/YamlWorkspaceBody.svelte | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web-common/src/features/generic-yaml-editor/YamlWorkspaceBody.svelte b/web-common/src/features/generic-yaml-editor/YamlWorkspaceBody.svelte index 89222a0e38b..6048be47d3f 100644 --- a/web-common/src/features/generic-yaml-editor/YamlWorkspaceBody.svelte +++ b/web-common/src/features/generic-yaml-editor/YamlWorkspaceBody.svelte @@ -7,6 +7,7 @@ import { runtime } from "../../runtime-client/runtime-store"; import { saveFile } from "./actions"; import ErrorPane from "./ErrorPane.svelte"; + import { debounce } from "@rilldata/web-common/lib/create-debouncer"; export let fileName: string; @@ -23,6 +24,8 @@ }, }); + const debouncedUpdate = debounce(handleUpdate, 300); + async function handleUpdate(e: CustomEvent<{ content: string }>) { const blob = e.detail.content; await saveFile(queryClient, fileName, blob); @@ -57,7 +60,7 @@ bind:this={editor} bind:view content={$file?.data?.blob || ""} - on:update={handleUpdate} + on:update={debouncedUpdate} />