Appearance
useSearchUtils Composable ​
File Information ​
- Path:
app/composables/core/common/useSearchUtils.ts - Purpose: Shared utilities for search functionality; reduces duplication across search composables
- Type: Core Composable (Common) — utility module
Overview ​
Exports constants, types, and pure functions used by search composables and the search page: debounce, scroll thresholds, pagination, error message extraction, request token management, and deep clone. Uses getApiErrorMessage from ~/utils/error for consistent API error display.
Constants ​
- SEARCH_DEBOUNCE_MS, FILTER_DEBOUNCE_MS: 300
- SCROLL_THRESHOLD_PERCENT: 85
- SCROLL_OFFSET_THRESHOLD: 36
- SMALL_SCREEN_BREAKPOINT: 1280
- SEARCH_RESULTS_PER_PAGE: 40
- INITIAL_PAGINATION_SIZE: 50
- DESCRIPTION_TRUNCATE_LENGTH: 250
- VISIBILITY_FILTER:
'(visibility:=0)'
Exports ​
- safeClearTimeout, createDebouncedFunction, createDebouncedFilterWrapper
- getSearchErrorMessage(error) — Prefers API message; 401/404/timeout-specific messages
- createRequestTokenManager() — Prevents stale search responses
- optimizedClone(value) — structuredClone with lodash cloneDeep fallback
- createScrollThrottle(scrollRafId, handler) — requestAnimationFrame throttle
- calculateScrollPercent(container), isScrollThresholdReached(container, threshold?)
- updateScreenWidth(screenWidth)
- createPaginationHelper(start, end, totalLength) — reset, update, isComplete
Related ​
- Composables - useSearch
- Utils - error - getApiErrorMessage