ensureInitialized method

  1. @override
Future<void> ensureInitialized()
override

Ensures this Paginated is initialized.

Implementation

@override
Future<void> ensureInitialized() async {
  Log.debug('ensureInitialized()', '$runtimeType');

  if (_futures.isEmpty && !status.value.isSuccess) {
    for (var f in initial) {
      if (f is Future<Map<K, T>>) {
        _futures.add(f..then(items.addAll));
      } else {
        items.addAll(f);
      }
    }

    await Future.wait(_futures);
    status.value = RxStatus.success();
    _futures.clear();
  } else {
    await Future.wait(_futures);
  }
}