@sixbell-telco/sdk
Version:
A collection of reusable components designed for use in Sixbell Telco Angular projects
38 lines (37 loc) • 1.67 kB
TypeScript
/**
* Async utility helpers for reliable DOM synchronization and timing control.
* These utilities provide browser-native timing mechanisms that are more reliable
* than hardcoded setTimeout values across different environments and platforms.
*/
export declare class SyncUtils {
/**
* Wait for next microtask (more reliable than setTimeout(0))
* Useful for ensuring state updates are processed before DOM operations
*/
static nextTick(): Promise<void>;
/**
* Wait for next animation frame (better for DOM updates)
* Ideal for synchronizing with browser rendering cycles
*/
static nextFrame(): Promise<void>;
/**
* Wait for DOM element to be available
* Useful for web components or dynamically created elements
*/
static waitForElement(selector: string, maxAttempts?: number): Promise<HTMLElement | null>;
/**
* Wait for a condition to be met with timeout
* Generic utility for polling-based waiting
*/
static waitForCondition(condition: () => boolean | Promise<boolean>, maxAttempts?: number, delayStrategy?: 'tick' | 'frame'): Promise<boolean>;
/**
* Debounce utility for preventing rapid successive calls
* Returns a debounced version of the provided function
*/
static debounce<T extends (...args: unknown[]) => unknown>(func: T, wait: number): (...args: Parameters<T>) => void;
/**
* Throttle utility for limiting function execution frequency
* Returns a throttled version of the provided function
*/
static throttle<T extends (...args: unknown[]) => unknown>(func: T, limit: number): (...args: Parameters<T>) => void;
}