call method

Effect call(
  1. Iterable<Bloom> targets,
  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 a throttle Effect attached to explicit targets.

Guarantees that action is executed at most once per duration window, preventing downstream I/O thrashing during high-frequency events.

  • targets: The collection of reactive Bloom nodes to monitor.
  • duration: The minimum time interval between consecutive executions.
  • action: The untracked callback to execute when triggered.
  • guard: Optional predicate gating execution and preserving tickets when returning false.
  • leading: Whether to execute on the leading edge of the time window. Defaults to true.
  • trailing: Whether to execute on the trailing edge if events arrived during cooldown. Defaults to true.
  • take: Optional maximum number of times this effect may execute.
  • 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 a throttle Effect attached to targets.

Throws:

Examples

final scroll = blooming(0.0);
final e = Effect.throttle(
  [scroll.bloom],
  const Duration(milliseconds: 100),
  () => syncScrollOffset(untracked(scroll.bloom)),
);

Implementation

@pragma('vm:prefer-inline')
Effect call(
  Iterable<Bloom> targets,
  Duration duration,
  void Function() action, {
  bool Function()? guard,
  bool leading = true,
  bool trailing = true,
  int? take,
  void Function(Object error, StackTrace stackTrace)? onUncaughtError,
}) =>
    _ManifestThrottleEffect(
      targets,
      duration,
      action,
      guard: guard,
      leading: leading,
      trailing: trailing,
      take: take,
      onUncaughtError: onUncaughtError,
    );