update method

  1. @visibleForTesting
  2. @protected
FutureOr<T?> update(
  1. FutureOr<T> updater(
    1. T old
    ), {
  2. dynamic onError(
    1. Object e,
    2. StackTrace s
    )?,
  3. int slowlyMs = 100,
  4. Object? debounceTag,
  5. Object? throttleTag,
  6. Object? mutexTag,
  7. @Deprecated('removed, set `Logger.root.level = Level.FINE` or lower to print SkipError') dynamic ignoreSkipError = true,
  8. @Deprecated('use logging') String onPutLogging(
    1. T cur
    )?,
  9. OnLogging<T>? logging,
})

Implementation

@visibleForTesting
@protected
FutureOr<T?> update(
  FutureOr<T> Function(T old) updater, {
  Function(Object e, StackTrace s)? onError,
  int slowlyMs = 100,
  Object? debounceTag,
  Object? throttleTag,
  Object? mutexTag,
  @Deprecated(
    'removed, set `Logger.root.level = Level.FINE` or lower to print SkipError',
  )
  ignoreSkipError = true,
  @Deprecated('use logging') String Function(T cur)? onPutLogging,
  OnLogging<T>? logging,
}) => runCatching<T>(
  () => updater(value),
  onSuccess:
      (r) => putWithLogging(
        r,
        logging:
            logging ??
            (onPutLogging == null ? null : (p, c) => onPutLogging(c)),
      ),
  onFailure: (e, s) {
    if (e is StateError && isClosed) {
      Error.throwWithStackTrace(e, s);
    }
    return (onError ?? putError).call(e, s);
  },
  slowlyMs: slowlyMs,
  debounceTag: debounceTag,
  throttleTag: throttleTag,
  mutexTag: mutexTag,
);