unary method

Effect unary(
  1. Bloom target,
  2. Duration duration,
  3. void action(), {
  4. bool guard()?,
  5. bool leading = true,
  6. bool trailing = true,
  7. int? take,
  8. void onUncaughtError(
    1. Object error,
    2. StackTrace stackTrace
    )?,
})

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 to true.
  • trailing: Whether to execute on the trailing edge. Defaults to true.
  • take: Optional execution limit before deactivation.
  • onUncaughtError: Optional error recovery handler.

Requires:

  • At least one of leading or trailing must be true.
  • If take is provided, it must be greater than or equal to 0.

Ensures:

  • Returns an optimized unary throttle Effect attached to target.

Throws:

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,
    );