What problem would this feature solve?
Allowing developers to declaratively set the lifetime of services (singleton, transient, scoped) improves ergonomics, aligns with top DI libraries, and makes service lifecycles explicit and easy to manage.
Proposed solution or design
Introduce decorators such as @Singleton, @Transient, and @Scoped, or provider options like { lifetime: 'singleton' | 'transient' | 'scoped' }. Store lifetime metadata at registration and resolve accordingly.
Additional context
See the NexusDI Roadmap: Lifetime Decorators for more details and proposed API.
What problem would this feature solve?
Allowing developers to declaratively set the lifetime of services (singleton, transient, scoped) improves ergonomics, aligns with top DI libraries, and makes service lifecycles explicit and easy to manage.
Proposed solution or design
Introduce decorators such as
@Singleton,@Transient, and@Scoped, or provider options like{ lifetime: 'singleton' | 'transient' | 'scoped' }. Store lifetime metadata at registration and resolve accordingly.Additional context
See the NexusDI Roadmap: Lifetime Decorators for more details and proposed API.