Learn
Lifecycle and teardown
Prevent new resolution during closing and dispose managed instances in reverse dependency order.
v0.1.0-dev.1Advancedark_di
Lifecycle and teardown
Closing changes the container from open to closing, rejects new top-level resolutions, waits for active resolution leases, plans teardown from recorded dependency edges, and runs disposers in reverse dependency order.
If Service depends on Repository, and Repository depends on Client, the order is:
text
Service → Repository → Client
All planned disposers are attempted. Multiple failures are reported together through DiCloseException; one failure does not skip unrelated cleanup. Repeated calls to close() return the same Future.
Circular resolution fails with DiCircularDependencyException and includes the dependency path that formed the cycle.