putAllAndUpdateExistingMapped<TMapped> method

  1. @override
Future<void> putAllAndUpdateExistingMapped<TMapped>(
  1. Map<TKey, TMapped> newValues,
  2. TVal mutateExisting(
    1. TKey key,
    2. TVal? mutateMe,
    3. TMapped newValue
    )
)
override

Same as putAllAndUpdateExisting but mutateExisting can receive a null existing value

Implementation

@override
Future<void> putAllAndUpdateExistingMapped<TMapped>(
  Map<TKey, TMapped> newValues,
  TVal Function(TKey key, TVal? mutateMe, TMapped newValue) mutateExisting,
) async {
  final actualNewValue = <TKey, TVal>{};
  for (var item in newValues.entries) {
    final key = item.key;
    final val = item.value;

    final res = await getValueById(key, defaultValue: null);
    actualNewValue[key] = mutateExisting(key, res, val);
  }
  await putAll(actualNewValue);
}