via method
Effect
via(
- void action(
- BloomVia via,
- EffectScope scope
- bool guard(
- BloomVia via
- void onUncaughtError(
- Object error,
- StackTrace stackTrace
Creates an explicit dynamic discovery Effect using BloomVia and EffectScope.
Schedules an initial evaluation on the microtask scheduler upon activation to discover
dynamic dependencies via via(node), providing an EffectScope to register turn
teardowns and observe lifecycle state.
Prior to subsequent evaluations or deactivation, the previous turn's EffectScope is marked cancelled and its registered cleanups are executed in LIFO order.
action: The dynamic tracking callback receiving BloomVia and EffectScope.guard: Optional boolean predicate evaluated with BloomVia prior to each execution.onUncaughtError: Optional error recovery handler.
Ensures:
- Returns a dynamic Effect with explicit BloomVia edge tracking and EffectScope lifecycle.
Examples
final e = Effect.scoped.via((via, scope) {
final endpoint = via(apiEndpoint.bloom);
final client = HttpClient(endpoint);
scope.onCleanup(client.close);
});
Implementation
@pragma('vm:prefer-inline')
Effect via(
void Function(BloomVia via, EffectScope scope) action, {
bool Function(BloomVia via)? guard,
void Function(Object error, StackTrace stackTrace)? onUncaughtError,
}) =>
_HandledViaEffect(
action,
guard: guard,
onUncaughtError: onUncaughtError,
);