load<T extends Document<T>> method

  1. @override
Future<T?> load<T extends Document<T>>(
  1. Document<T> document, {
  2. Source source = Source.serverAndCache,
  3. void fromCache(
    1. T?
    )?,
})
override

Implementation

@override
Future<T?> load<T extends Document<T>>(
  Document<T> document, {
  Source source = Source.serverAndCache,
  void Function(T?)? fromCache,
}) async {
  if (fromCache != null) {
    try {
      final cache = await _load(document, Source.cache);
      fromCache(cache != null ? cache as T : null);
    } on Exception catch (_) {
      fromCache(null);
    }
  }
  final document0 = await _load(document, source);
  return document0 != null ? document0 as T : null;
}