waitTask method

Future<void> waitTask({
  1. required String indexName,
  2. required int taskID,
  3. WaitParams params = const WaitParams(),
  4. RequestOptions? requestOptions,
})

Wait for a taskID to complete before executing the next line of code, to synchronize index updates. All write operations in Algolia are asynchronous by design. It means that when you add or update an object to your index, our servers will reply to your request with a taskID as soon as they understood the write operation. The actual insert and indexing will be done after replying to your code. You can wait for a task to complete by using the taskID and this method.

Implementation

Future<void> waitTask({
  required String indexName,
  required int taskID,
  WaitParams params = const WaitParams(),
  RequestOptions? requestOptions,
}) async {
  await _waitUntil(
    params: params,
    retry: () => getTask(
      indexName: indexName,
      taskID: taskID,
      requestOptions: requestOptions,
    ),
    until: (response) => response.status == TaskStatus.published,
  );
}