Learn
Registrations and ownership
Choose Instance, Factory, Lazy Singleton, async strategies, and explicit ownership correctly.
v0.1.0-dev.1Intermediateark_di
Registrations and ownership
| Strategy | Resolution result | Retained by container |
|---|---|---|
| Instance | supplied object | yes, as a registration |
| Factory | new object per request | no |
| Async Factory | new Future result per request | no |
| Lazy Singleton | one object after first request | yes |
| Async Lazy Singleton | one successful async result | yes |
DiOwnership.container means the container closes the registered Instance when a disposer is supplied. DiOwnership.external records that another owner controls its lifecycle.
A Factory is transient: the consumer that receives its object controls its reachability and lifecycle. Ark DI does not retain each Factory result in a hidden list.