AsyncTeardownScope class

A teardown scope over an AsyncContext: nodes created through it are disposed when it ends (#lzspecedgeindex).

The async counterpart of the synchronous TeardownScope, and the same shape for the same reason: Dart has no destructor, so the end of a scope has to be a statement. AsyncContext.withScope brackets it around a callback; end ends it explicitly for the case a callback cannot express — a scope whose lifetime is a connection or a subscription, opened in one callback and ended in another.

end is a Future because effect teardown awaits the effect's pending cleanup; that is the async graph's existing disposal contract (docs/async.md § Cancellation contract, rule 5) and a scope must not weaken it.

Properties

ctx AsyncContext
The context this scope belongs to.
final
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Whether this scope owns nothing.
no setter
isEnded bool
Whether end has already run.
no setter
isNotEmpty bool
Whether this scope owns at least one node.
no setter
length int
How many nodes this scope currently owns.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

adopt<T extends AsyncGraphNode>(T node) → T
Take ownership of an existing node. Adopting into an ended scope is a no-op rather than an immediate disposal — the scope's moment has passed.
cell<T>(T value) AsyncCellHandle<T>
Create a source cell owned by this scope.
computedAsync<T>(Future<T> compute(AsyncComputeContext ctx)) AsyncSlotHandle<T>
Create a computed async slot owned by this scope.
disarm() → void
Cancel this scope's teardown: ending it afterwards disposes nothing, and its nodes revert to plain context ownership. The nodes themselves are untouched — same values, same edges in both directions, still individually disposable.
effectAsync(Future body(AsyncComputeContext ctx)) AsyncEffectHandle
Register an async effect owned by this scope.
end() Future<void>
Dispose every node this scope owns, in reverse creation order — dependents before what they read, so the scope never transiently dangles inside itself. Idempotent.
memoAsync<T>(Future<T> compute(AsyncComputeContext ctx), Equals<T> eq) AsyncSlotHandle<T>
Create a memoized async slot owned by this scope.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited