You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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
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.
(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:
Qualifiers support can be extended in three ways:
val
/def
where the instance is wiredwire[Service1 with RedQualifier]
, and then at usage-site:class Service2(s1: Service1 with RedQualifiers)
; and of the simple wrapper-types as well.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.
The text was updated successfully, but these errors were encountered: