Created
January 15, 2026 10:39
-
-
Save jacobsapps/c61528b13ea92f2b4b947ea8ce911e0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol SearchService { | |
| // stream results directly to view model | |
| var searchResults: AsyncStream<[User]> | |
| func search(query: String) async throws | |
| // cursor-based pagination | |
| func nextPage(query: String, after user: User) -> async throws | |
| } | |
| final class SearchServiceImpl: SearchService { | |
| private var searchTask: Task<Void, Error>? | |
| func search(query: String) async throws { | |
| searchTask?.cancel() | |
| searchTask = { | |
| try Task.checkCancellation() | |
| // perform search network request | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment