why not pass priority and useWeakReference to the addViewListener and addContextListener function in Mediator

airycanon's Avatar

airycanon

24 Jul, 2014 07:30 AM

Hi
I find that the mapListener function in IEventMap cound accept this two arguments,so why doesn't Mediator accept and pass them to IEventMap?
Sorry for my poor English and thanks for this great framework.

  1. Support Staff 1 Posted by Ondina D.F. on 25 Jul, 2014 09:13 AM

    Ondina D.F.'s Avatar

    Hi,

    You have 2 options:

    • use the eventMap.mapListener instead of addViewListener or addContextListener, and set the priority and useWeakReference as you wish them to be :
    eventMap.mapListener(view,  SomeEvent.SOME_DATA_REQUESTED, 
    dispatch, false, 11, false);
    
    eventMap.mapListener( eventDispatcher,  SomeEvent.SOME_DATA_RECEIVED, 
    someHandler, false, 1, true);
    

    In my experience, having useWeakReference set to true is a good thing almost always, and I can't think of a scenario where the opposite were desirable for a Mediator's event listener. As for the priorities of event listeners, personally, I try to avoid relying on a specific order of execution of event listeners. More often than not, there are other architectural solutions to that problem. I'm curious as to why you need to change those parameters. What is your special/particular use case?

    Ondina

  2. 2 Posted by airycanon on 29 Jul, 2014 01:18 AM

    airycanon's Avatar

    Hi Ondina,
    In my use case,both mediatorA and mediatorB have the same event listeners,and i need to make mediatorA's event handler happen first,as you said there are other solutions to this problem,thanks for your replies.

  3. Support Staff 3 Posted by Ondina D.F. on 30 Jul, 2014 08:15 AM

    Ondina D.F.'s Avatar

    No problem:)

  4. Ondina D.F. closed this discussion on 30 Jul, 2014 08:15 AM.

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