unary method
Creates an optimized unary throttle Effect attached to a single explicit target.
target: The single Bloom node to monitor.duration: The minimum time interval between consecutive executions.action: The untracked callback to execute.guard: Optional predicate gating execution.leading: Whether to execute on the leading edge. Defaults totrue.trailing: Whether to execute on the trailing edge. Defaults totrue.take: Optional execution limit before deactivation.onUncaughtError: Optional error recovery handler.
Requires:
- At least one of
leadingortrailingmust betrue. - If
takeis provided, it must be greater than or equal to0.
Ensures:
- Returns an optimized unary throttle Effect attached to
target.
Throws:
- ArgumentError if both
leadingandtrailingarefalse. - RangeError if
takeis negative.
Examples
final scroll = blooming(0.0);
final e = Effect.throttle.unary(
scroll.bloom,
const Duration(milliseconds: 100),
() => syncScrollOffset(untracked(scroll.bloom)),
);
Implementation
@pragma('vm:prefer-inline')
Effect unary(
Bloom target,
Duration duration,
void Function() action, {
bool Function()? guard,
bool leading = true,
bool trailing = true,
int? take,
void Function(Object error, StackTrace stackTrace)? onUncaughtError,
}) =>
_UnaryManifestThrottleEffect(
target,
duration,
action,
guard: guard,
leading: leading,
trailing: trailing,
take: take,
onUncaughtError: onUncaughtError,
);