call method

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

Creates a debounce Effect attached to explicit targets.

Defers execution of action until duration has elapsed since the most recent mutation.

  • targets: The collection of reactive Bloom nodes to monitor.
  • duration: The silence window duration required before executing action.
  • action: The untracked callback to execute when the debounce window settles.
  • guard: Optional predicate gating execution and preserving tickets when returning false.
  • leading: Whether to execute action immediately on the first mutation. Defaults to false.
  • trailing: Whether to execute action on the trailing edge after silence elapses. Defaults to true.
  • take: Optional maximum number of times this effect may execute before early teardown.
  • onUncaughtError: Optional error callback invoked when action or guard throws an uncaught exception.

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 debounce Effect attached to targets.

Throws:

Examples

final query = blooming('');
final e = Effect.debounce(
  [query.bloom],
  const Duration(milliseconds: 300),
  () => apiService.search(untracked(query.bloom)),
);

Implementation

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