Roots and owners
Every memo and effect belongs to an owner. Disposing that owner runs its cleanups and disposes its children. Disposing it again is safe.
The owner can be the graph's Root, a scope created by createRoot, or the current run of an enclosing effect, owning memo or boundary.
Create a scope
createRoot bodycreates a scope, runsbodywith itsOwner, and returnsbody's result.owner.Dispose ()disposes everything created inside that scope.graph.Dispose ()disposes every node the graph owns. Useuse graph = new Graph ()to dispose the graph automatically when the enclosing scope ends.
In this replay, disposing the root removes its effect's dependency. The signal remains available, but later writes no longer run that effect.
Disposal
Disposal order and nested roots
An owner runs its cleanups first, then disposes its children. Each group runs in reverse creation order.
A root created inside an effect belongs to that effect's current run. It is disposed before the effect's next run.
Register subscriptions and other resources with Cleanup.