throttle method
Defines an explicit rate-limited throttle Effect attached to this node.
Rate-limits triggers to at most once per duration.
duration: The minimum time interval between consecutive executions.action: The untracked callback to execute when triggered.guard: Optional boolean 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 early teardown.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 a unary throttle Effect attached to this node.
Examples
final scroll = blooming(0.0);
final effect = scroll.bloom.effect.throttle(
const Duration(milliseconds: 100),
() => syncScroll(untracked(scroll.bloom)),
);
Implementation
@pragma('vm:prefer-inline')
Effect throttle(
Duration duration,
void Function() action, {
bool Function()? guard,
bool leading = true,
bool trailing = true,
int? take,
void Function(Object error, StackTrace stackTrace)? onUncaughtError,
}) =>
Effect.throttle.unary(
_target,
duration,
action,
guard: guard,
leading: leading,
trailing: trailing,
take: take,
onUncaughtError: onUncaughtError,
);