Repository navigation
PickableItems 1.1.0
This minor release adds support for external and async autocomplete sources (such as server-backed tag search APIs) while remaining 100% backwards-compatible with 1.0.0.
What's New
- Async
searchProviderinitializer: Pass a(String) async throws -> [Item]closure toKeyboardPickableItemCoordinatorwhen your data source already handles filtering and sorting.PickableItemsautomatically debounces keystrokes, cancels stale in-flight requests, preserves your provider's result ordering, and filters out selected items. - Loading & error state: Observe
coordinator.isLoading(for example, to show aProgressViewin a trailing accessory) andcoordinator.searchErrorfor non-cancellation errors. - Configurable
debounceDuration: Customize the search debounce delay on both local and remote coordinators (defaults to300ms). - Smarter selection updates: Selecting or deselecting items in remote mode re-filters the cached results without triggering redundant network calls.
Example
@State private var coordinator = KeyboardPickableItemCoordinator<RemoteTag>(
debounceDuration: .milliseconds(300)
) { query in
guard query.count >= 2 else { return [] }
return try await apiClient.autocompleteTags(matching: query)
}