-
Notifications
You must be signed in to change notification settings - Fork 25
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Description
Since server-side Swift projects like Vapor now support async/await APIs, it would nice if meilisearch-swift also added this.
Basic example
As opposed to the completion parameter style currently used, an async/await call would look like so:
let result = await index.updateDocuments(documents: [/** data **/], primaryKey: "id")
switch result {
case .success:
// ....
case .failure(let error):
// ....
}
Proposed solution
I have already created extensions in my local project to support some of the methods that I use. For example updateDocuments()
is covered by this implementation:
public func updateDocuments<T>(
documents: [T],
encoder: JSONEncoder? = nil,
primaryKey: String? = nil) async -> Result<TaskInfo, Swift.Error> where T: Encodable {
return await withCheckedContinuation { continuation in
self.updateDocuments(documents: documents, encoder: encoder, primaryKey: primaryKey) { res in
continuation.resume(returning: res)
}
}
}
Proposal is to add these bridging methods for all methods on Indexes
in perhaps an Indexes+async.swift
extension. Additionally unit tests will need to be added to cover async calls.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request