createLocalDoc method

  1. @protected
DTO createLocalDoc({
  1. required CreateDocDef<DTO, MODEL> doc,
  2. bool doNotifyListeners = true,
})

Creates a new document in local state.

Parameters:

  • doc - The document to create
  • doNotifyListeners - Whether to notify listeners of the change

Implementation

@protected
DTO createLocalDoc({
  required CreateDocDef<DTO, MODEL> doc,
  bool doNotifyListeners = true,
}) {
  final pDoc = doc(vars());
  log.debug('Creating local doc with id: ${pDoc.id}');
  if (doNotifyListeners) {
    beforeLocalNotifyUpdate?.call(pDoc);
  }
  _doc.update(
    modelBuilder(this, null, pDoc),
    doNotifyListeners: doNotifyListeners,
  );
  if (doNotifyListeners) {
    afterLocalNotifyUpdate?.call(pDoc);
  }
  return pDoc;
}