📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
Add a new debounced function with delayed execution in utils
Axel MINART992c20c65268
diff --git a/frontend/app/composables/utils.ts b/frontend/app/composables/utils.tsindex 2483d7d5..8b4a258d 100644--- a/frontend/app/composables/utils.ts+++ b/frontend/app/composables/utils.ts@@ -62,3 +62,28 @@ export function debounce<T extends (...args: unknown[]) => void>(fn: T, delay =}};}++/**+ * Creates a debounced version of the provided function that delays its execution until after+ * a specified wait time has elapsed since the last time it was invoked. Unlike the standard+ * debounce, this version only executes the function after the delay period, and resets the timer+ * on each call (no immediate execution).+ *+ * @param fn - The function to debounce.+ * @param delay - The number of milliseconds to delay invocation (default: 2000).+ * @returns A debounced function that delays invoking `fn` until after `delay` ms have elapsed since the last call.+ */+export function debounceDelayed<T extends (...args: unknown[]) => void>(fn: T, delay = 2000) {+ let timeout: ReturnType<typeof setTimeout> | null = null;++ return (...args: Parameters<T>) => {+ // Annuler le timer précédent+ if (timeout) clearTimeout(timeout);++ // Lancer un nouveau timer+ timeout = setTimeout(() => {+ fn(...args);+ timeout = null;+ }, delay);+ };+}\ No newline at end of file