load method

Future<List<T>> load({
  1. Source source = Source.serverAndCache,
  2. void fromCache(
    1. List<T>
    )?,
})

Implementation

Future<List<T>> load({
  Source source = Source.serverAndCache,
  void Function(List<T>)? fromCache,
}) async {
  if (fromCache != null) {
    try {
      final cacheDocuments = await _load(source: Source.cache);
      fromCache(cacheDocuments.map(decode).cast<T>().toList());
    } on Exception catch (_) {
      fromCache([]);
    }
  }
  final documents = await _load(source: source);
  return documents.map(decode).cast<T>().toList();
}