mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-03-23 18:15:08 +00:00
feat: oidc client data preview (#624)
Co-authored-by: Elias Schneider <login@eliasschneider.com>
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
export function debounced<T extends (...args: any[]) => void>(func: T, delay: number) {
|
||||
export function debounced<T extends (...args: any[]) => any>(
|
||||
func: T,
|
||||
delay: number,
|
||||
onLoadingChange?: (loading: boolean) => void
|
||||
) {
|
||||
let debounceTimeout: ReturnType<typeof setTimeout>;
|
||||
|
||||
return (...args: Parameters<T>) => {
|
||||
@@ -6,8 +10,14 @@ export function debounced<T extends (...args: any[]) => void>(func: T, delay: nu
|
||||
clearTimeout(debounceTimeout);
|
||||
}
|
||||
|
||||
debounceTimeout = setTimeout(() => {
|
||||
func(...args);
|
||||
onLoadingChange?.(true);
|
||||
|
||||
debounceTimeout = setTimeout(async () => {
|
||||
try {
|
||||
await func(...args);
|
||||
} finally {
|
||||
onLoadingChange?.(false);
|
||||
}
|
||||
}, delay);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user