-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
waitForPendingUpdate method #6
Comments
@curquiza Is this feature really needed? The Swift library is 100% async by design. |
Hey @ppamorim ppamorim!
This function aims to create a waiting function for the second case, not the first/ When I look into your tests I observe this self.client.addOrReplaceDocument(
UID: uid,
document: document,
primaryKey: primaryKey) { result in
switch result {
case .success(let update):
XCTAssertEqual(stubUpdate, update)
expectation.fulfill()
case .failure:
XCTFail("Failed to add or replace Movies document")
}
}
self.wait(for: [expectation], timeout: 1.0) If I read your code correctly. On the last line of this code block, you wait for The idea with self.client.addOrReplaceDocument(
UID: uid,
document: document,
primaryKey: primaryKey) { result in
switch result {
case .success(let update):
XCTAssertEqual(stubUpdate, update)
self.client. waitForPendingUpdate(
UID: uid,
updateId: update["updateId"]) { result in
switch result {
case .success(let updateInfo):
XCTAssertEqual("processed", update.status)
expectation.fulfill()
case .failure:
XCTFail("Failed to add or replace Movies document")
}
}
}
case .failure:
XCTFail("Failed to add or replace Movies document")
}
}
self.wait(for: [expectation], timeout: 1.0) This will ensur that the documents have been processed and thus added correctly to MeiliSearch. The user will be able to wait upon any asynchronous MeiliSearch process and not just the MeiliSearch server response. In this case, the user is now sure all of his documents have been added and he can use the search. Maybe I understood swift wrongly. But in the case I did not, do you feel this has more sense ? |
@bidoubiwa Oh nice I will implement this! Thank you for the complete explanation. |
Issue fully detailed here.
The text was updated successfully, but these errors were encountered: