download method

  1. @override
Future<List<ValidationRule>?> download(
  1. dynamic callback(
    1. RequestProgress,
    2. bool
    ), {
  2. Dio? dioTestClient,
})
override

Implementation

@override
Future<List<ValidationRule>?> download(
    Function(RequestProgress, bool) callback,
    {Dio? dioTestClient}) async {
  List<DataSet> dataSets = await DataSetQuery(database: database).get();

  final queue = Queue(parallel: 50);
  num availableItemCount = 0;

  dataSets.forEach((dataSet) {
    availableItemCount++;
    queue.add(() =>
        this.downloadOne(dataSet, availableItemCount, (progress, complete) {
          callback(progress, complete);
        }, dioTestClient: dioTestClient));
  });

  if (availableItemCount == 0) {
    queue.cancel();
  } else {
    await queue.onComplete;
  }

  return this.get();
}