-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
410: Add async overload for search API r=curquiza a=Sherlouk # Pull Request⚠️ I've marked this as draft as it current works to provide an example of how we could add async/await support to the library. I am more than happy to expand this to **all** currently supported APIs. ## Related issue Relates to #332 (doesn't close as only adds support for one API) ## What does this PR do? - Adds an async/await override to an existing search API providing users with more choice. ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: James Sherlock <[email protected]>
- Loading branch information
Showing
4 changed files
with
68 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Foundation | ||
|
||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) | ||
extension Indexes { | ||
/** | ||
Search in the index. | ||
|
||
- Parameter searchParameters: Options on search. | ||
- Throws: Error if a failure occurred. | ||
- Returns: On completion if the request was successful a `Searchable<T>` instance is returned containing the values. | ||
*/ | ||
public func search<T: Codable & Equatable>(_ searchParameters: SearchParameters) async throws -> Searchable<T> { | ||
try await withCheckedThrowingContinuation { continuation in | ||
self.search.search(self.uid, searchParameters) { result in | ||
continuation.resume(with: result) | ||
} | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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