ViewMap.as Event.ADDED_TO_STAGE handling & it's performance

Tomas Mirezko's Avatar

Tomas Mirezko

12 Mar, 2011 06:16 PM

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!

  1. 1 Posted by Michal Wroblews... on 12 Mar, 2011 07:43 PM

    Michal Wroblewski's Avatar

    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.

  2. Support Staff 2 Posted by Stray on 12 Mar, 2011 10:10 PM

    Stray's Avatar

    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

  3. 3 Posted by Michal Wroblews... on 12 Mar, 2011 10:23 PM

    Michal Wroblewski's Avatar

    Yep. Forgot about it :)

    And it's the newest one (no changes from eidiot)

  4. 4 Posted by Tomas Mirezko on 13 Mar, 2011 10:52 AM

    Tomas Mirezko's Avatar

    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.

  5. 5 Posted by Michal Wroblews... on 13 Mar, 2011 11:12 AM

    Michal Wroblewski's Avatar

    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.

  6. 6 Posted by Michal Wroblews... on 13 Mar, 2011 02:06 PM

    Michal Wroblewski's Avatar

    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

  7. 7 Posted by Tomas Mirezko on 13 Mar, 2011 05:04 PM

    Tomas Mirezko's Avatar

    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));

  8. 8 Posted by Michal Wroblews... on 14 Mar, 2011 10:49 AM

    Michal Wroblewski's Avatar

    Updated now. I hope that Shaun will accept pull request soon. Previous update is already pushed to @darscan fork.

  9. Tomas Mirezko closed this discussion on 15 Mar, 2011 07:42 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac