CommandMap listening for events on main displayList

Tim Oxley's Avatar

Tim Oxley

04 Jan, 2010 04:26 AM

Because the contextView that is passed to the context is itself an eventDispatcher, is there a reason Robotlegs needs to use it's own separate EventDispatcher instance instead of the one provided by the contextView?

This would mean I can dispatch events from my view components that can trigger commands without needing a mediator (for example from an item renderer on a generic List component), or is this breaking mvc?

edit: It also means we can avoid some boilerplate "forwarding events from view to main event bus" code

  1. Support Staff 1 Posted by Joel Hooks on 04 Jan, 2010 05:55 AM

    Joel Hooks's Avatar

    You can use the ViewMap and inject directly into your views (give them an EventMap or whatever). I would never do this myself, but I wouldn't generally use the ViewMap or put any framework bits on my components. If you are talking about bubbling events up to the context view to trigger commands... :<

    Using a separate IEventDispatcher is explicit, and frankly proper. I believe at one point in time the contextView was the IEventDispatcher that was inject, but thankfully it has been changed to an explicit separate EventDispatcher. Injecting the root contextView all over the place, even as an interface smells awful. Also bubbled custom events could trigger "double" commands or other oddities that would be incredibly hard to debug.

  2. 2 Posted by Tim Oxley on 06 Jan, 2010 12:34 AM

    Tim Oxley's Avatar

    Yeah I figured it was something like that. I've been instructed to go into "Rush the project out" mode and as such I'm writing untested, ill-architected code and lots of code is going into my views when it really should be in mediators, thus I wanted to trigger commands from the view.

    Refactoring the code into mediators solves this issue and is where the code should probably be anyway. Thanks Joel.

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