dependy 1.7.0
dependy: ^1.7.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.7.0 #
Features #
- Provider decorators: Added optional
decoratorsparameter toDependyProvider. Decorators are composable transformations applied after the factory creates the base instance, inside the provider's singleton caching. Each decorator receives the instance and aresolvefunction for resolving additional dependencies from the module. Decorators are applied in list order — first decorator wraps the raw instance, second wraps the first's output, etc. Works with singletons (decorated once, cached), transients (decorated on every call), tagged providers, eager modules, andoverrideWith. AddedDependyDecorate<T>typedef.debugGraph()now shows decorator counts.
1.6.0 #
Features #
- Debug graph: Added
debugGraph()method toDependyModuleandEagerDependyModule. Returns a formatted ASCII tree of the entire dependency graph showing provider types, tags, keys, lifecycle (singleton/transient), resolution status (pending/cached/always new), disposed state, and nested submodules. Useful during development for inspecting what's registered and resolved.
1.5.0 #
Features #
- Overrides for testing: Added
overrideWithmethod toDependyModule. Create a new module with specific providers replaced by (Type, tag) match — perfect for swapping real services with mocks in tests. The original module is not modified, making it safe for parallel tests. Full verification runs on the new module so misconfigurations are caught early.
1.4.0 #
Features #
- Tagged instances: Added optional
tagparameter toDependyProviderfor registering multiple instances of the same type. Resolve withmodule<T>(tag: 'name'). Tags work with singletons, transients, submodules, eager modules, and all verification checks (duplicates, circular dependencies, captive dependencies).
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 = awaitdependyModule.asEager();
// Now you can call services directly
final myService = eagerModule<MyService>();