fetch method
Fetch data from
- Memory
- Firebase cache if not available in memory
- Firestore server if not available in cache
in the given order for the given ref
.
Implementation
Future<T> fetch(DocumentReference ref) async {
final completer = Completer();
_fetch(ref, completer);
final memItem = _items[ref.path];
if (memItem != null) {
return memItem;
}
final item = await _addon.tryFetch(
ref: ref,
source: Source.cache,
);
if (item != null) {
_items[ref.path] = item;
return item;
}
await completer.future;
return _items[ref.path]!;
}