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

Qualifier support #9

Closed
adamw opened this issue Jun 25, 2014 · 2 comments
Closed

Qualifier support #9

adamw opened this issue Jun 25, 2014 · 2 comments

Comments

@adamw
Copy link
Member

adamw commented Jun 25, 2014

(One of the ideas from ScalaDays 2014)

Qualifiers are used to distinguish between instances of the same type, and are necessary to be able to support wiring when there's more than one instance of the searched type in the wiring scope.

Currently with MacWire there are two work-arounds for the problem:

  • when qualifiers would have to be used, use manual wiring
  • use descriptive types to differentiate between different values (simple wrapper classes, value classes etc.)

Qualifiers support can be extended in three ways:

  1. support annotation qualifiers, as in CDI, for example. The annotation would have to be present on the usage side (where the dependency should be "injected") and on the declaration side, either on the class or on the val/def where the instance is wired
  2. document and verify that things work as expected the approach using "type qualifiers". E.g. this may take the form of wire[Service1 with RedQualifier], and then at usage-site: class Service2(s1: Service1 with RedQualifiers); and of the simple wrapper-types as well.
  3. Support parameters in wire[] to override dependencies #7 may also provide a solution for the problem

I feel that 2. is more Scala-way and that's what should be documented/implemented.

If there's sufficient demand, in fact both 1. and 2. can be documented/implemented independently.

@szimano
Copy link
Member

szimano commented Jun 25, 2014

+1 for the scala way in option 2 ;-)

@adamw
Copy link
Member Author

adamw commented Dec 1, 2014

adamw added a commit that referenced this issue Dec 17, 2014
@adamw adamw closed this as completed Dec 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants