dependy 1.3.0
dependy: ^1.3.0 copied to clipboard
Dependy is a lightweight and flexible dependency injection (DI) library for Dart. It simplifies the management of services and their dependencies.
Changelog #
1.3.0 #
Features #
- Transient providers: Added
transientparameter toDependyProvider. Whentrue, a fresh instance is created on every resolution instead of caching a singleton. - Captive dependency detection:
DependyModulenow throwsDependyCaptiveDependencyExceptionat construction time if a singleton provider depends on a transient provider, preventing the silent capture of transient instances.
Infrastructure #
- Migrated to Dart pub workspace (monorepo) structure.
1.2.0 #
Features #
- EagerDependyModule:
- Introduced the
EagerDependyModuleclass for eager resolution of dependencies. - Users can convert a
DependyModuleinto anEagerDependyModule
- Introduced the
New Extension Method #
asEager():- Added an extension method on
DependyModulethat creates an instance ofEagerDependyModule.
- Added an extension method on
Code Example #
final dependyModule = DependyModule(providers: { /* providers here */
});
// Eagerly resolve all providers
final eagerModule = await
dependyModule.asEager
();
// Now you can call services directly
final myService = eagerModule<MyService>();