resolve method

  1. @override
Future<DatumConflictResolution<T>> resolve({
  1. T? local,
  2. T? remote,
  3. required DatumConflictContext context,
})
override

Resolves a conflict between a local and remote version of an entity.

Implementation

@override
Future<DatumConflictResolution<T>> resolve({
  T? local,
  T? remote,
  required DatumConflictContext context,
}) async {
  if (local == null && remote == null) {
    return DatumConflictResolution.abort(
      'No entities supplied to merge resolver.',
    );
  }

  if (local == null || remote == null) {
    return DatumConflictResolution.abort(
      'Merge requires both local and remote data to be available.',
    );
  }

  final merged = await onMerge(local, remote, context);

  if (merged == null) {
    return DatumConflictResolution.abort('User cancelled merge operation.');
  }

  return DatumConflictResolution.merge(merged);
}