@adventurelabs/scout-core
Version:
Core utilities and helpers for Adventure Labs Scout applications
39 lines (38 loc) • 1.42 kB
TypeScript
export interface UseScoutRefreshOptions {
autoRefresh?: boolean;
onRefreshComplete?: () => void;
}
/**
* Hook for refreshing scout data with detailed timing measurements
*
* @param options - Configuration options for the refresh behavior
* @param options.autoRefresh - Whether to automatically refresh on mount (default: true)
* @param options.onRefreshComplete - Callback function called when refresh completes
*
* @returns Object containing:
* - handleRefresh: Function to manually trigger a refresh
* - getTimingStats: Function to get detailed timing statistics for the last refresh
*
* @example
* ```tsx
* const { handleRefresh, getTimingStats } = useScoutRefresh();
*
* // Get timing stats after a refresh
* const stats = getTimingStats();
* console.log('Herd modules API took:', stats.herdModulesApi, 'ms');
* console.log('User API took:', stats.userApi, 'ms');
* console.log('Data processing took:', stats.dataProcessing, 'ms');
* console.log('LocalStorage operations took:', stats.localStorage, 'ms');
* console.log('Total duration:', stats.totalDuration, 'ms');
* ```
*/
export declare function useScoutRefresh(options?: UseScoutRefreshOptions): {
handleRefresh: () => Promise<void>;
getTimingStats: () => {
totalDuration: number;
herdModulesApi: number;
userApi: number;
dataProcessing: number;
localStorage: number;
};
};