pyqt_reactive.services.search_service

Shared search service for UI components.

This module provides a framework-agnostic search service that can be used by both PyQt and Textual implementations to ensure consistent search behavior across the application.

Classes

SearchService(all_items, ...[, min_chars])

Framework-agnostic search service with minimum character trigger.

class pyqt_reactive.services.search_service.SearchService(all_items: Dict[str, T], searchable_text_extractor: Callable[[T], str], min_chars: int = 2)[source]

Framework-agnostic search service with minimum character trigger.

This service provides consistent search behavior across PyQt and Textual implementations, ensuring the same code path is used for all search operations.

Key features: - Minimum character threshold (default: 2) - Customizable searchable text extraction - Performance optimization for short searches

MIN_SEARCH_CHARS = 2
__init__(all_items: Dict[str, T], searchable_text_extractor: Callable[[T], str], min_chars: int = 2)[source]

Initialize search service.

Parameters:
  • all_items – Dictionary of all searchable items (key -> item)

  • searchable_text_extractor – Function to extract searchable text from an item

  • min_chars – Minimum characters required to trigger search (default: 2)

filter(search_term: str) Dict[str, T][source]

Filter items based on search term.

This is the canonical search implementation used across all UI frameworks.

Parameters:

search_term – Search string to filter by

Returns:

Dictionary of filtered items

reset()[source]

Reset filter to show all items.

update_items(new_items: Dict[str, T])[source]

Update the items being searched.