Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module annotation #8

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.3.0

- Added annotation `DependencyModule`

## 1.2.1

- Changed the interfaces from `List` to `Set`
Expand Down
27 changes: 27 additions & 0 deletions lib/src/annotations/annotations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,30 @@ class RegisterFactoryMethod {
/// Constructs a registration entry for a factory method, highlighting its use in service instantiation.
const RegisterFactoryMethod();
}

/// Marks a class as a dependency registration module within the service locator.
///
/// This annotation is used to designate a class that contains methods or getters annotated
/// with [RegisterInstance], [RegisterFactory], [RegisterLazy], or [RegisterFactoryMethod],
/// each defining a specific service registration. The `DependencyModule` serves as a container
/// for organizing multiple service registrations in a structured and cohesive manner.
///
/// By grouping service registrations within a module, it promotes a centralized and modular approach
/// to dependency management, making the DI configuration more maintainable and scalable.
///
/// Example usage:
/// ```dart
/// @DependencyModule()
/// class MyAppRegistrationModule {
/// @RegisterSingleton
/// SomeService get someService => SomeServiceImpl();
///
/// @RegisterFactory
/// AnotherService createAnotherService() => AnotherServiceImpl();
/// }
/// ```
class DependencyModule {
/// Constructs a `DependencyModule` annotation, marking the annotated class as a container for
/// service registration definitions.
const DependencyModule();
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: zef_di_abstractions
description: A dart library which provides abstractions for dependency injection.
version: 1.2.1
version: 1.3.0
homepage: https://www.zooper.dev
repository: https://github.com/zooper-lib/ZEF_DI_Abstractions
topics:
Expand Down
Loading