unary method
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 executingaction.action: The untracked callback to execute.guard: Optional predicate gating execution and preserving tickets when returningfalse.leading: Whether to execute on the leading edge. Defaults tofalse.trailing: Whether to execute on the trailing edge. Defaults totrue.take: Optional execution limit before deactivation.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 an optimized unary debounce Effect attached to
target.
Throws:
- ArgumentError if both
leadingandtrailingarefalse. - RangeError if
takeis negative.
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,
);