0

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;
}

?

Joel Hooks
  • 6,465
  • 4
  • 33
  • 39
Totty.js
  • 15,563
  • 31
  • 103
  • 175

2 Answers2

0

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.

Joel Hooks
  • 6,465
  • 4
  • 33
  • 39
0

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.

Franky-D
  • 450
  • 4
  • 16