Skip to content

Commit

Permalink
Rename sleep util file and move debounce into it
Browse files Browse the repository at this point in the history
  • Loading branch information
kylanhurt committed Dec 5, 2023
1 parent 66b59bf commit 3f89b6a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/components/HeaderSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { OptionsObj, TableByScope } from 'src/types';
import { api } from 'src/api';
import { isValidTransactionHex } from 'src/utils/string-utils';
import { useQuasar } from 'quasar';
import { debounce } from 'src/utils/string-utils';
import { debounce } from 'src/utils/time';
export default defineComponent({
name: 'HeaderSearch',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ProposalItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import sha256 from 'fast-sha256';
import { ABI, ABIDef, Action, Serializer, Transaction } from '@greymass/eosio';
import { useStore } from 'src/store';
import { deserializeActionDataFromAbi } from 'src/api/eosio_core';
import { sleep } from 'src/utils/sleep';
import { sleep } from 'src/utils/time';
export default defineComponent({
name: 'ProposalItem',
Expand Down
3 changes: 0 additions & 3 deletions src/utils/sleep.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/utils/string-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,3 @@ export function getRexHistoryAsset(data: RexHistory): string {
return data.amount;
}
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const debounce = <T extends (...args: any[]) => ReturnType<T>>(
callback: T,
timeout: number,
): ((...args: Parameters<T>) => void) => {
console.log('debouncing');
let timer: ReturnType<typeof setTimeout>;

return (...args: Parameters<T>) => {
clearTimeout(timer);
timer = setTimeout(() => {
callback(...args);
}, timeout);
};
};
19 changes: 19 additions & 0 deletions src/utils/time.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export function sleep(timeout = 1000): Promise<void> {
return new Promise(r => setTimeout(r, timeout));
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const debounce = <T extends (...args: any[]) => ReturnType<T>>(
callback: T,
timeout: number,
): ((...args: Parameters<T>) => void) => {
console.log('debouncing');
let timer: ReturnType<typeof setTimeout>;

return (...args: Parameters<T>) => {
clearTimeout(timer);
timer = setTimeout(() => {
callback(...args);
}, timeout);
};
};

0 comments on commit 3f89b6a

Please sign in to comment.