Skip to content

Commit 338faad

Browse files
committed
Update README to use async example
1 parent 6f0291d commit 338faad

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

README.md

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -149,24 +149,13 @@ With the `uid` of the task, you can check the status (`enqueued`, `canceled`, `p
149149
#### Basic Search <!-- omit in toc -->
150150

151151
```swift
152-
153-
let semaphore = DispatchSemaphore(value: 0)
154-
155-
// Typealias that represents the result from Meilisearch.
156-
typealias MeiliResult = Result<SearchResult<Movie>, Swift.Error>
157-
158-
// Call the function search and wait for the closure result.
159-
client.index("movies").search(SearchParameters( query: "philoudelphia" )) { (result: MeiliResult) in
160-
switch result {
161-
case .success(let searchResult):
162-
dump(searchResult)
163-
case .failure(let error):
164-
print(error.localizedDescription)
165-
}
166-
semaphore.signal()
152+
do {
153+
// Call the search function and wait for the result.
154+
let result: SearchResult<Movie> = try await client.index("movies").search(SearchParameters(query: "philoudelphia"))
155+
dump(result)
156+
} catch {
157+
print(error.localizedDescription)
167158
}
168-
semaphore.wait()
169-
170159
```
171160

172161
Output:
@@ -191,6 +180,8 @@ Output:
191180

192181
Since Meilisearch is typo-tolerant, the movie `philadelphia` is a valid search response to `philoudelphia`.
193182

183+
> Note: All package APIs support closure-based results for backwards compatibility. Newer async/await variants are being added under [issue 332](https://github.com/meilisearch/meilisearch-swift/issues/332).
184+
194185
## 🤖 Compatibility with Meilisearch
195186

196187
This package guarantees compatibility with [version v1.x of Meilisearch](https://github.com/meilisearch/meilisearch/releases/latest), but some features may not be present. Please check the [issues](https://github.com/meilisearch/meilisearch-swift/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+label%3Aenhancement) for more info.

0 commit comments

Comments
 (0)