call method
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 executingaction.action: The untracked callback to execute when the debounce window settles.guard: Optional predicate gating execution and preserving tickets when returningfalse.leading: Whether to executeactionimmediately on the first mutation. Defaults tofalse.trailing: Whether to executeactionon the trailing edge after silence elapses. Defaults totrue.take: Optional maximum number of times this effect may execute before early teardown.onUncaughtError: Optional error callback invoked whenactionorguardthrows an uncaught exception.
Requires:
- At least one of
leadingortrailingmust betrue. - If
takeis provided, it must be greater than or equal to0.
Ensures:
- Returns a debounce Effect attached to
targets.
Throws:
- ArgumentError if both
leadingandtrailingarefalse. - RangeError if
takeis negative.
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,
);