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. @Deprecated('removed slowly') int slowlyMs = 100,
  4. @Deprecated('removed slowly') Object? debounceTag,
  5. @Deprecated('removed slowly') Object? throttleTag,
  6. dynamic ignoreSkipError = true,
})

updater if return value, will call put if return null, will not call put/putError onError if set null,will call putError if set function value, will not call putError, you can invoke putError manually slowlyMs if set <=0 value, will ignore debounce/throttleTag debounceTag enable debounce, require unique within the VM scope throttleTag enable throttle, require unique within the VM scope ignoreSkipError ref runCatching.ignoreSkipError

Implementation

@visibleForTesting
@protected
FutureOr<T?> update(
  FutureOr<T> Function(T old) updater, {
  Function(Object e, StackTrace s)? onError,
  @Deprecated('removed slowly') int slowlyMs = 100,
  @Deprecated('removed slowly') Object? debounceTag,
  @Deprecated('removed slowly') Object? throttleTag,
  ignoreSkipError = true,
}) => runCatching<T>(
  () => updater(value),
  onSuccess: (r) => put(r),
  onFailure: (e, s) => (onError ?? putError).call(e, s),
  ignoreSkipError: ignoreSkipError,
);