update method
FutureOr<T?>
update(
- FutureOr<
T> updater(- T old
- dynamic onError(
- Object e,
- StackTrace s
- int slowlyMs = 100,
- Object? debounceTag,
- Object? throttleTag,
- Object? mutexTag,
- @Deprecated('removed, set `Logger.root.level = Level.FINE` or lower to print SkipError') dynamic ignoreSkipError = true,
- @Deprecated('use logging') String onPutLogging(
- T cur
- 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,
);