unary method

Effect unary(
  1. Bloom target,
  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 an optimized unary debounce Effect attached to a single explicit target.

  • target: The single Bloom node to monitor.
  • duration: The silence window duration required before executing action.
  • action: The untracked callback to execute.
  • guard: Optional predicate gating execution and preserving tickets when returning false.
  • leading: Whether to execute on the leading edge. Defaults to false.
  • 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 debounce Effect attached to target.

Throws:

Examples

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

Implementation

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