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

New Alias annotation #389

Merged
merged 5 commits into from Apr 7, 2024
Merged

New Alias annotation #389

merged 5 commits into from Apr 7, 2024

Conversation

Blacksmoke16
Copy link
Member

@Blacksmoke16 Blacksmoke16 commented Apr 7, 2024

  • Replaces the alias key with a new ADI::AsAlias annotation
    • Accepts alias name as the first positional argument, or if not provided will try to infer it from the included interfaces (modules ending in Interface). If there is only 1, that type is used.
      • A string key may also be provided to alias other concrete services.
  • Re-organizes some of the specs to move them into where the logic is actually running

The use case for string keys is you can do something like this:

@[ADI::Register(name: "default_router")]
@[ADI::AsAlias("router")]
class Router
end

To have a service with an internal default_router id, but alias it to a more general router id. Then dependencies can be wired up to depend upon the "@router" implementation. This would allow users to in theory override the router alias to their own implementation (assuming it implements same API/interface(s)), and everything would just pick up on that w/o having to touch the original default_router. I could see this being useful at some point.

Resolves part of #385.

@Blacksmoke16 Blacksmoke16 merged commit 48ee843 into master Apr 7, 2024
10 checks passed
@Blacksmoke16 Blacksmoke16 deleted the as-alias branch April 7, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

1 participant