feat(editor): Migrate debounce mixin to useDebounce composable (no-changelog) (#8244)

This commit is contained in:
Alex Grozav
2024-01-08 14:00:49 +02:00
committed by GitHub
parent 8affdf680d
commit 8c8caac4e8
19 changed files with 136 additions and 106 deletions

View File

@@ -1,30 +0,0 @@
import { debounce } from 'lodash-es';
import { defineComponent } from 'vue';
export const debounceHelper = defineComponent({
data() {
return {
debouncedFunctions: {} as Record<string, (...args: unknown[]) => Promise<void> | void>,
};
},
methods: {
async callDebounced(
functionName: string,
options: { debounceTime: number; trailing?: boolean },
...inputParameters: unknown[]
): Promise<void> {
const { trailing, debounceTime } = options;
if (this.debouncedFunctions[functionName] === undefined) {
this.debouncedFunctions[functionName] = debounce(
async (...args: unknown[]) => {
// @ts-ignore
await this[functionName](...args);
},
debounceTime,
trailing ? { trailing } : { leading: true },
);
}
await this.debouncedFunctions[functionName](...inputParameters);
},
},
});