waitForFirstSync method

Future<void> waitForFirstSync({
  1. BucketPriority? priority,
})
inherited

Returns a Future which will resolve once at least one full sync cycle has completed (meaninng that the first consistent checkpoint has been reached across all buckets).

When priority is null (the default), this method waits for the first full sync checkpoint to complete. When set to a BucketPriority however, it completes once all buckets within that priority (as well as those in higher priorities) have been synchronized at least once.

Implementation

Future<void> waitForFirstSync({BucketPriority? priority}) async {
  bool matches(SyncStatus status) {
    if (priority == null) {
      return status.hasSynced == true;
    } else {
      return status.statusForPriority(priority).hasSynced == true;
    }
  }

  if (matches(currentStatus)) {
    return;
  }
  await for (final result in statusStream) {
    if (matches(result)) {
      break;
    }
  }
}