updateLocalDoc method

  1. @protected
T updateLocalDoc({
  1. required String id,
  2. required UpdateDocDef<T> doc,
  3. bool doNotifyListeners = true,
})

Updates an existing document in local state.

Parameters:

  • id - The document ID
  • doc - The document update function
  • doNotifyListeners - Whether to notify listeners of the change

Implementation

@protected
T updateLocalDoc({
  required String id,
  required UpdateDocDef<T> doc,
  bool doNotifyListeners = true,
}) {
  if (_doc.value == null) {
    throw StateError('Cannot update non-existent document');
  }
  final pDoc = doc(_doc.value!, turboVars(id: id));
  log.debug('Updating local doc with id: ${pDoc.id}');
  if (doNotifyListeners) {
    beforeLocalNotifyUpdate?.call(pDoc);
  }
  _doc.update(pDoc, doNotifyListeners: doNotifyListeners);
  if (doNotifyListeners) {
    afterLocalNotifyUpdate?.call(pDoc);
  }
  return pDoc;
}