Effect.via constructor
- void action(
- BloomVia via
- bool guard(
- BloomVia via
- void onUncaughtError(
- Object error,
- StackTrace stackTrace
Creates an explicit dynamic discovery Effect using BloomVia.
Unlike manifest effects which skip initial evaluation, Effect.via schedules
an initial evaluation on the microtask scheduler upon activation to dynamically
discover dependencies accessed through via(node).
-
Re-runs
actionwhenever any dynamically observed node mutates. -
Automatically prunes stale dependencies and registers new dependencies during re-evaluation (1-pass epoch diffing).
-
If
guardis provided, it is evaluated with BloomVia before each run; returningfalseskips execution. -
If
onUncaughtErroris provided, it is invoked when an uncaught exception occurs. -
action: The dynamic tracking callback receiving BloomVia. -
guard: Optional boolean predicate evaluated with BloomVia prior to each execution. -
onUncaughtError: Optional error recovery handler.
Ensures:
Examples
final a = blooming(1);
final b = blooming(2);
final e = Effect.via((via) {
print('Dynamic sum: ${via(a.bloom) + via(b.bloom)}');
});
Implementation
@pragma('vm:prefer-inline')
factory Effect.via(
void Function(BloomVia via) action, {
bool Function(BloomVia via)? guard,
void Function(Object error, StackTrace stackTrace)? onUncaughtError,
}) =>
_ViaEffect(
action,
guard: guard,
onUncaughtError: onUncaughtError,
);