Core concepts¶
This section is the mental model behind diwire. If you prefer learning by doing, start with the Tutorial (runnable examples) tutorial and use these pages as the “why it works” reference.
Recommended order¶
Container - auto-wiring, what gets resolved, and how keys work
Registration - explicit registration, decorators, and interfaces
Lifetimes - transient vs singleton vs scoped
Scopes & cleanup - request-like scopes and deterministic cleanup
Function injection - injecting into functions with
Injected()Named components - multiple implementations via
Component("name")Open generics - open generic registrations and type-safe resolution
Async - async factories, async cleanup, and
aresolve()container_context - global context container for framework integration
Compilation - precomputing the graph for speed
Errors & debugging - common error modes and how to debug them
Integrations - dataclasses/pydantic/attrs/msgspec notes