Sorry to be ignorant but I still don't quite understand how are
objects created / obtained from the container. So say that in MyView
(which is nested somewhere in the main application), I need to
instantiate MyPresenter. I want to do it in the initialize or
creationComplete event handler. Without an IoC container, I would do
something like:
function onCreateionComplete() : void {
this.presenter = new MyPresenter(this, new Dependency1(), new
Dependency2());
}
I want to avoid this because Dependency1 and Dependency2 may have
already been created for some other presenter or object up the logical
hierarchy. I have 2 options: either pass the dependencies manually
through the chain of nested Views, or use a Service Locator pattern.
The first option is cumbersome and I generally prefer DI over Service
Locator.
I would hope that SmartyPants will allow me to do something like this:
* in some global bootstrapping code, I would define Presenter's
dependencies using SmartyPants' rules
* here in the onCreationComplete() method, I would just call something
like SmartyPants.getInstanceOf(MyPresenter).
Can this be achieved with SmartyPants IoC? (Obviously, the problem is
how to pass on the view reference and I would probably need to do that
manually after the presenter reference has been obtained - something
like myPresenter.view = this.)
Thanks,
Borek