Reputation: 15831
I would like to know which one is better/faster/lighter?
[Inject]
public var myInjection:MyInjection;
OR
[Inject]
public var injector:IInjector;
protected var _myInjection:MyInjection;
public function get myInjection():MyInjection{
if(!_myInjection) _myInjection = injector.getInstance(MyInjection);
return _myInjection;
}
?
Upvotes: 0
Views: 276
Reputation: 450
I have a feeling that the first is faster. SwiftSuspenders keeps a cache of injection points for each injectee - the second method would probably not take advantage of that caching.
Upvotes: 0
Reputation: 6565
well the first one is appropriate. The second is weird.
You've injected the IInjector in a couple of questions. In all of the robotlegs apps I've built I have never needed to inject the injector. The only time I've needed to do that is when I was writing framework extensions/utils.
Upvotes: 0