call method
- Iterable<
Bloom> targets, - void action(
- EffectScope scope
- bool guard()?,
- int? take,
- void onUncaughtError(
- Object error,
- StackTrace stackTrace
Creates a manifest Effect attached strictly to explicit targets providing an EffectScope.
-
Skips initial evaluation (0 runs upon construction/mount).
-
Executes
actionwith an injected EffectScope in an untracked environment when any oftargetsmutate. -
Prior to subsequent evaluations or deactivation, the previous turn's EffectScope is marked cancelled and its registered cleanup callbacks are executed in LIFO order.
-
If
guardis provided and returnsfalse, execution is skipped andtaketickets are preserved. -
If
takeis provided, executes at mosttaketimes and then automatically deactivates (Early Teardown). -
If
onUncaughtErroris provided, it is invoked on uncaught exceptions. -
targets: The reactive Bloom nodes to monitor for mutations. -
action: The untracked callback receiving an EffectScope to invoke upon mutation. -
guard: Optional boolean predicate gating execution. -
take: Optional limit on execution count before automatic deactivation. -
onUncaughtError: Optional error recovery handler.
Requires:
- If
takeis provided, it must be greater than or equal to0.
Ensures:
- Returns a scoped Effect bound to
targets.
Throws:
- RangeError if
takeis negative.
Examples
final room = blooming('lobby');
final e = Effect.scoped([room.bloom], (scope) {
final timer = Timer.periodic(const Duration(seconds: 5), (_) => ping());
scope.onCleanup(timer.cancel);
});
Implementation
@pragma('vm:prefer-inline')
Effect call(
Iterable<Bloom> targets,
void Function(EffectScope scope) action, {
bool Function()? guard,
int? take,
void Function(Object error, StackTrace stackTrace)? onUncaughtError,
}) =>
_HandledManifestEffect(
targets,
action,
guard: guard,
take: take,
onUncaughtError: onUncaughtError,
);