Is the Inject metadata really needed
I came across this article from Joel Hooks today, looks like it was written about a year ago and if I am reading it correctly, it looks as if the inject meta tag is not necessary? does this mean I can just use
private var _model:Model = new Model();
instead of
[Inject] public var model:Model;
Comments are currently closed for this discussion. You can start a new one.
2 Posted by Michal Wroblewski on 27 Jun, 2011 08:22 PM
Hi Joe,
You little misunderstood the article. It was about too many different metatags across frameworks, also promoting Robotlegs as a framework that only needs one metatag [Inject]. So to use it correctly always use [Inject] metatag:
If you use your first case you always get new Model instance and then no chance to share the same instance in your context.
Cheers,
Michal
Support Staff 3 Posted by creynders on 28 Jun, 2011 07:29 AM
Actually the inject metadata is not necessary, but obviously you need to inform the injector somehow where injections are needed, therefore you can pass a XML string to the constructor describing all the injection points.
See "XML configuration of injection points" at
https://github.com/tschneidereit/SwiftSuspenders/blob/master/README...
Support Staff 4 Posted by creynders on 29 Jun, 2011 08:28 AM
Extra note: the example from Joel you're referring to uses constructor injection, w/o inject metadata tags or the XML config of the injections. If SS encounters constructor parameters it automatically injects them with mapped values.
Stray closed this discussion on 21 Jul, 2011 03:24 PM.