Question

in my context:

var parserManager:ParserManager = injector.instantiate(ParserManager);
parserManager.injector = injector;
injector.mapValue(ParserManager, parserManager);

in my parserManager(doesn't extend any other class) class:

public var injector:IInjector;

the parserManager is injected in some models. Is there a better way of doing it? this is so dirty..

Was it helpful?

Solution

injector.mapSingleton(ParserManager);
var parserManager:Parser = injector.getInstance(ParserManager);

in ParserManager:

[Inject]
public var injector:IInjector

I am a little suspect of injecting the injector into a class with Manager in its name, but that is about the cleanest way I can think of to get it done.

You should keep in mind that after the manager has been mapped, if you don't need it immediately then it will be injected with the injector when it is first created (by being injected in another class that uses it). Robotlegs creates instances lazily.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top