vue3-maplibre-gl
Version:
Vue 3 components and composables for MapLibre GL JS - Build interactive maps with ease
63 lines (62 loc) • 2.69 kB
TypeScript
import { ComputedRef } from 'vue';
/**
* Options for optimized computed properties
*/
interface OptimizedComputedOptions<T> {
/** Enable deep equality checking (default: false) */
deepEqual?: boolean;
/** Custom equality function */
equalityFn?: (a: T, b: T) => boolean;
/** Cache duration in milliseconds (default: no expiration) */
cacheDuration?: number;
}
/**
* Creates an optimized computed property with caching and equality checking
* Prevents unnecessary re-computations when values haven't actually changed
*
* @param getter - The computed getter function
* @param options - Optimization options
* @returns Optimized computed ref
*/
export declare function useOptimizedComputed<T>(getter: () => T, options?: OptimizedComputedOptions<T>): ComputedRef<T>;
/**
* Creates a memoized function with caching
* Useful for expensive operations that depend on reactive data
*
* @param fn - Function to memoize
* @param keyFn - Function to generate cache key
* @param maxCacheSize - Maximum cache size (default: 100)
* @returns Memoized function
*/
export declare function useMemoized<TArgs extends any[], TReturn>(fn: (...args: TArgs) => TReturn, keyFn?: (...args: TArgs) => string, maxCacheSize?: number): (...args: TArgs) => TReturn;
/**
* Creates a computed property that only updates when dependencies change significantly
* Useful for expensive computations that should be throttled
*
* @param getter - The computed getter function
* @param threshold - Minimum change threshold (for numbers)
* @param debounceMs - Debounce delay in milliseconds
* @returns Throttled computed ref
*/
export declare function useThrottledComputed<T extends number>(getter: () => T, threshold?: number, debounceMs?: number): ComputedRef<T>;
/**
* Creates a computed property with automatic cleanup
* Useful for computed properties that create resources
*
* @param getter - The computed getter function
* @param cleanup - Cleanup function for old values
* @returns Computed ref with cleanup
*/
export declare function useComputedWithCleanup<T>(getter: () => T, cleanup: (oldValue: T) => void): ComputedRef<T>;
/**
* Creates a computed property that batches updates
* Useful for computed properties that trigger multiple reactive updates
*
* @param getter - The computed getter function
* @param batchSize - Number of updates to batch (default: 5)
* @param batchDelay - Delay between batches in milliseconds (default: 16)
* @returns Batched computed ref
*/
export declare function useBatchedComputed<T>(getter: () => T, batchSize?: number, batchDelay?: number): ComputedRef<T>;
export {};
//# sourceMappingURL=useOptimizedComputed.d.ts.map