TypedSaveConflictHandler<D extends TypedDocumentObject<Object> , MD extends TypedMutableDocumentObject<TypedDocumentObject<Object> , TypedDocumentObject<Object> > > typedef
Database
Typed Data
- @experimental
Custom conflict handler for saving a typed document.
This handler is called if the save would cause a conflict, i.e. if the document in the database has been updated (probably by a pull replicator, or by application code) since it was loaded into the document being saved.
The documentBeingSaved
(same as the parameter you passed to
SaveTypedDocument.withConflictHandler.) may be modify by the callback as
necessary to resolve the conflict.
The handler receives the revision of the conflictingDocument
currently in
the database, which has been changed since documentBeingSaved
was loaded.
It can be be null
, meaning that the document has been deleted.
The handler has to make a decision by returning true
to save the document
or false
to abort the save.
If the handler throws the save will be aborted.
See also:
- SaveTypedDocument.withConflictHandler for saving a typed document with a custom conflict handler.
Implementation
@experimental
typedef TypedSaveConflictHandler<D extends TypedDocumentObject,
MD extends TypedMutableDocumentObject>
= FutureOr<bool> Function(
MD documentBeingSaved,
D? conflictingDocument,
);