Totty.js
Totty.js

Reputation: 15831

Is better/faster/lighter to inject with metatag or with getters? actionscript 3 / flex

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

Answers (2)

Franky-D
Franky-D

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

Joel Hooks
Joel Hooks

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

Related Questions