Instead of getting a specific (singleton) bean instance there is a factory behind which always returns a new instance of the bean you try to autowire. Damn this is really a great feature which I also needed in my current project. I solved it differently until now but I will refactor to the Prototype approach which makes my code a lot cleaner since Swiz has to worry about the bean creation and not me!
Let’s assume every SomeView.mxml needs a single instance of SomeController. The code in the BeanLoader would look like this:
<?xml version="1.0" encoding="utf-8"?> <BeanLoader xmlns="org.swizframework.util.*"> <factory:Prototype xmlns:factory="org.swizframework.factory.*" id="someController" className="foo.controllers.SomeController"/> </BeanLoader>
And in SomeView.mxml you autowire:
[Autowire(bean="someController")] public var someController:SomeController;
Now every instance of SomeView get’s it’s own instance of SomeController. Ohhsumm Chris!