Effect.unary constructor
- Bloom target,
- void action(), {
- bool guard()?,
- int? take,
- void onUncaughtError(
- Object error,
- StackTrace stackTrace
Creates an optimized unary manifest Effect attached strictly to a single explicit target.
Provides zero-allocation fast-path dispatch by bypassing intermediate List allocations
and linking directly via a specialized unary edge terminal.
-
Skips initial evaluation (0 runs upon construction/mount).
-
Executes
actionin an untracked environment whentargetmutates. -
If
guardis provided and returnsfalse, execution is skipped andtaketickets are preserved. -
If
takeis provided, executes at mosttaketimes and then automatically deactivates and detaches fromtarget(Early Teardown). -
If
onUncaughtErroris provided, it is invoked when an uncaught exception is thrown inactionorguard. -
target: The single Bloom node to monitor. -
action: The untracked callback 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 an optimized unary manifest Effect bound to
target.
Throws:
- RangeError if
takeis negative.
Examples
final query = blooming('');
final e = Effect.unary(query.bloom, () {
print('Query changed to: ${untracked(query.bloom)}');
});
Implementation
@pragma('vm:prefer-inline')
factory Effect.unary(
Bloom target,
void Function() action, {
bool Function()? guard,
int? take,
void Function(Object error, StackTrace stackTrace)? onUncaughtError,
}) =>
_UnaryManifestEffect(
target,
action,
guard: guard,
take: take,
onUncaughtError: onUncaughtError,
);