ViewMap.as Event.ADDED_TO_STAGE handling & it's performance
Hi Robots!
I was wondering, if there are performance issues with ADDED_TO_STAGE in ViewMap.as class, as this event fires a lot in games.
Are there any examples how to do manual mediator creation/registration and turn off this ADDED_TO_STAGE handling?
I am concerned only for performance, I would like to use it as it is though.
Thanks!
Comments are currently closed for this discussion. You can start a new one.
2 Posted by Michal Wroblewski on 12 Mar, 2011 07:43 PM
Hi Tomas,
I think you have to extend MediatorMap and set _active value to false ( then it will not set listeners like ADDED_TO_STAGE and REMOVED_FROM_STAGE ). They take very much of the performance. Then you map views as usual with autoCreate and autoRemove set to false (in fact it doesn't matter if you set _active to false). Anyway. To create a mediator you need to inject mediatorMap and use mediatorMap.createMediator(viewInstance). That's all.
Support Staff 3 Posted by Stray on 12 Mar, 2011 10:10 PM
There's also a utility - LazyMediatorMap - which is ideal for this:
https://github.com/darscan/robotlegs-utilities-LazyMediator
That's Shaun's fork - it'd be worth checking out which is the newest on github.
Stray
4 Posted by Michal Wroblewski on 12 Mar, 2011 10:23 PM
Yep. Forgot about it :)
And it's the newest one (no changes from eidiot)
5 Posted by Tomas Mirezko on 13 Mar, 2011 10:52 AM
Thanks very much, LazyMediatorMap seems like it!
However I can't compile as I don't have _active:Boolean field in robotlegs/robotlegs-framework ViewMapBase class. Should I use some unofficial branch? I like official one.
6 Posted by Michal Wroblewski on 13 Mar, 2011 11:12 AM
Latest version of Robotlegs is missing _active field. Now I remember @jhooks and @darscan discussing about that field. So you just need to remove the usage of that field manually. Now Robotlegs has only enabled field which means the same (that's why _active was removed.) I'll try to fork LazyMediator from @darscan, push changes and ask @darscan to merge branches from me.
7 Posted by Michal Wroblewski on 13 Mar, 2011 02:06 PM
I finally managed to make a commit to GitHub fork. I also sent pull request to @darscan. Here is my fork compatible with Robotlegs v.1.4.0+ https://github.com/wrobel221/robotlegs-utilities-LazyMediator
8 Posted by Tomas Mirezko on 13 Mar, 2011 05:04 PM
Michal, could you update README.textile as well?
LazyMediatorMap needs 3rd argument - reflector
Override the mediatorMap getter method in context to:
return mediatorMap || (mediatorMap = new LazyMediatorMap(contextView, injector, reflector));
9 Posted by Michal Wroblewski on 14 Mar, 2011 10:49 AM
Updated now. I hope that Shaun will accept pull request soon. Previous update is already pushed to @darscan fork.
Tomas Mirezko closed this discussion on 15 Mar, 2011 07:42 PM.