* 🔥 Remove `tslint.json` * 🔥 Remove TSLint commands * 🔥 Remove exceptions in `editor-ui` * 🔥 Remove from `.npmignore` * 🔥 Remove from `eslint-config` * 🔥 Remove exception from `design-system` * 🎨 Prettify * 📦 Update pnpm-lock * 🔥 Remove duplicate import * 🔥 Remove exemption for `no-explicit-any` * 👕 Inline `no-explicit-any` exemptions
30 lines
798 B
TypeScript
30 lines
798 B
TypeScript
import { debounce } from 'lodash';
|
|
import Vue from 'vue';
|
|
|
|
export const debounceHelper = Vue.extend({
|
|
data() {
|
|
return {
|
|
debouncedFunctions: [] as any[],
|
|
};
|
|
},
|
|
methods: {
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
async callDebounced(...inputParameters: any[]): Promise<void> {
|
|
const functionName = inputParameters.shift() as string;
|
|
const { trailing, debounceTime } = inputParameters.shift();
|
|
|
|
// @ts-ignore
|
|
if (this.debouncedFunctions[functionName] === undefined) {
|
|
// @ts-ignore
|
|
this.debouncedFunctions[functionName] = debounce(
|
|
this[functionName],
|
|
debounceTime,
|
|
trailing ? { trailing } : { leading: true },
|
|
);
|
|
}
|
|
// @ts-ignore
|
|
await this.debouncedFunctions[functionName].apply(this, inputParameters);
|
|
},
|
|
},
|
|
});
|