The created scope.
Creates a scope and returns the value produced by the callback.
This is shorthand for creating a scope and immediately running the callback inside it. Without an explicit parent, the created scope is owned by the current active scope. When no scope is active, it becomes a root scope.
Only the synchronous execution of the callback belongs to this scope. Work created after an await no longer belongs to this scope.
If the callback returns a promise, that promise is returned as-is and is not awaited.
Cleanup callbacks registered while the callback runs belong to this scope and run together when scope.dispose is called. Scope-local
values written during that time also belong to this scope. Nested scopes are owned the same way.
scope.onDispose registers additional cleanup callbacks on this scope. Only the synchronous part of the callback belongs to the
scope, so work created after an await would no longer belong to it.
If the callback throws, the created scope is disposed immediately. If scope disposal also fails, the callback error is listed first in the resulting aggregate error.
The value returned by the callback.
Creates a scope under the given explicit parent scope and returns the callback result.
The value returned by the callback.
Creates a scope.
Without an explicit parent, the created scope is owned by the current active scope. When no scope is active, it becomes a root scope.
The returned scope can be activated later through Scope.run and disposed through Scope.dispose or dispose.