justinfagnani / dado

An experimental dependency injection container for Dart
BSD 3-Clause "New" or "Revised" License
9 stars 6 forks source link

Select the constructor to use via an annotation #2

Open justinfagnani opened 11 years ago

justinfagnani commented 11 years ago

Instead of choosing the no-name constructor, Dado should choose the constructor based on the presence of an @inject annotation.

We can still fall back to the current constructor selection heuristic if no annotation is present.

Dreckr commented 11 years ago

Should we fallback to the current constructor selection or only fallback to a no-args constructor and warn the user if there is none? The second behavior should prevent the user from forgetting to annotate the desired constructor with @inject, where the former could cause some confusion. (I have the later one implemented already, but that's easy to change)

justinfagnani commented 11 years ago

I think falling back on the current behavior is good. If there's only one constructor, try to use it. This could be an option on the injector though.

Dreckr commented 11 years ago

Patch at #9 . I have not added the option to select the fallback behavior as I find it would add unnecessary clutter. Current behavior seems fine.