Open
Description
It would be very nice if inject could control the dependency construction process, rather than the developer needing to manually instantiate them in the correct order and Map()'ing them in. This could be thought of as evaluating a dependency graph.
Something like this:
type Provider interface {
Provide(ifacePtr interface{}, constructor func(*TypeMapper) interface{})
}
Then the TypeMapper, on request of a type that it does not have in is values map, would invoke the Provider to create it. Could also do some sort of infinite regression protection, too, in the event of an inadvertent dependency loop.
Alas, I can't think of a more declarative way to do it, and interface{}
makes me sad.
What do you think, @codegangsta? I apologise for the presumptuous design ticket. ;)
Metadata
Metadata
Assignees
Labels
No labels