EventDispatcher - prevent RL-component from receiving Event that it dispatches.

andreas's Avatar

andreas

10 Dec, 2013 12:05 PM

Hi,

I am using the global EventDispatcher from the default Starling-viewmap in all my Mediators:

[Inject]
public var eventDispatcher:flash.events.IEventDispatcher;

I have one custom Event that my model dispatches when the user edits the data in one of the UI-elements and that all my Mediators are listening on.
Is there a best practice to prevent the Mediator of the UI that has the changes from receiving this update-event?
Do I set my UI in some "edit" state and ignore the update-event when it gets received?
Do I add some target to my event (the ui/mediator-object) and ignore the event when this target is the current UI-Element?

  1. Support Staff 1 Posted by Ondina D.F. on 10 Dec, 2013 01:25 PM

    Ondina D.F.'s Avatar

    Hi Andreas,

    Do I set my UI in some "edit" state and ignore the update-event when it gets received?

    Yes, why not. You can use states or booleans or something else.

    You can set a boolean, say, "iDontCare" to true when the view is dispatching the event in question, and in the method that the mediator is accessing when the model dispatches the change event, you set iDontCare to false and then just return.

    Or, you could do the same on a mediator level, before it re-dispatches view's event, and then let the mediator decide whether it should react to the model's event or not, i.e. whether it should pass the data on to its view or not.

    Do I add some target to my event (the ui/mediator-object) and ignore the event when this target is the current UI-Element?

    Yes, you can pass along a view ID as the payload of the event dispatched by the view, but I think the first option is easier to implement.

    Maybe there are other options as well, but I can't think of any right now.

    Ondina

  2. 2 Posted by andreas on 10 Dec, 2013 01:42 PM

    andreas's Avatar

    Hi Ondina,

    Thank you very much for your quick and helpful response!
    I will use an edit-state for my UI than.

    Have a Great day.

    Andreas

  3. Support Staff 3 Posted by Ondina D.F. on 10 Dec, 2013 01:56 PM

    Ondina D.F.'s Avatar

    My pleasure!
    Thanks for the wishes, same to you:)

  4. Ondina D.F. closed this discussion on 10 Dec, 2013 01:56 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