tryUpdate method

RxResult<V> tryUpdate(
  1. K key,
  2. V update(
    1. V value
    ), {
  3. V ifAbsent()?,
})

Update value with error handling

Implementation

RxResult<V> tryUpdate(K key, V Function(V value) update,
    {V Function()? ifAbsent}) {
  return RxResult.tryExecute(() {
    final newMap = Map<K, V>.from(value);
    final result = newMap.update(key, update, ifAbsent: ifAbsent);
    value = newMap;
    return result;
  }, 'update map value');
}