Get the current active context
OptionalattachExperimental
Imperatively sets context as active, returning a ContextManagementToken whose
ContextManagementToken.dispose method restores the previous context.
This is a delicate, low-level API - prefer with/bind, which
restore context automatically. attach exists only to bridge callback
boundaries that with cannot wrap. The caller is responsible for disposing
the token via token.dispose() when the operation is complete. Support is
optional and best-effort; when omitted, ContextAPI.attach logs a
warning and returns a no-op token.
Caveat for async functions: If called inside an async function before
the first await, the context change may leak into the caller's context
and remain active there. Prefer with for async code.
The Context to attach
A ContextManagementToken whose dispose() restores the previous Context
Disable context management
Enable context management
Since
1.0.0