applyOptimistic method
Publish the current dirty fields through the graph patch layer.
Implementation
void applyOptimistic() {
if (!state.isDirty || _optimisticApplied) return;
final graph = ref.read(entityGraphProvider);
final existing = graph.readEntityPatch(type, id) ?? const {};
_previousSyncMetadata = graph.syncMetadata(type, id);
_previousPatchValues = {
for (final key in state.dirtyPaths)
if (existing.containsKey(key)) key: existing[key],
};
_previouslyAbsentPatchKeys = state.dirtyPaths
.where((key) => !existing.containsKey(key))
.toSet();
graph.patchEntity(type, id, state.edits);
graph.markEntityOptimistic(type, id);
_optimisticApplied = true;
}