updateLocalDoc method
T
updateLocalDoc({
- required String id,
- required UpdateDocDef<
T> doc, - bool doNotifyListeners = true,
Updates an existing document in local state.
Parameters:
id
- The document IDdoc
- The document update functiondoNotifyListeners
- 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;
}