The PureMVC Framework
Code at the Speed of Thought
Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
New discussions should be taken up in issues on the appropriate projects at
PureMVC Architects Lounge
Announcements and General Discussion
Topic: Mediators Sequence/Priority (Read 6032 times)
September 11, 2007, 02:16:35 »
Firstly, congrats on sharing this excellent project.
I need to enable/disable mediators without using register/remove in order to keep their creation sequence/priority.
The mediators must work much like interceptors, keeping their sequence (data and transformation dependency)
Imagine the following scenario: I have 3 Mediators, registered to the same view, to Analyze, Record and Broadcast user interactions:
How can I disable/enable only the GestureRecorderMediator without using removeMediator/registerMediator?
Is there a different approach to keep the registered priority/sequence using those methods? (How about override facade.notifyObservers in order to filter the notifications to the mediators that are flagged to enable)
Re: Mediators Sequence/Priority
Reply #1 on:
September 11, 2007, 04:20:45 »
Overriding Facade.notifyObservers wouldn't work in this case, as it just passes through the notification to the View.notifyObservers method. And, since the the other Mediators still need to be notified, you'd still need to send every notification. Taking this tack, you'd have to override the View.notifyObservers method, AND you'd need to give the View a list of disabled mediators to skip. AND you'd need some extra methods to manage that list AND some Commands to make it all happen.
I believe the direction I would take is:
1) Give the Mediator a Boolean 'enabled' property.
2) Whenever you need to enable or disable this Mediator, send a special Notification (i.e. DISABLE_GESTURE_RECORDER or ENABLE_GESTURE_RECORDER) that only the GestureRecorderMediator has interest in, and to which it responds by setting its own enabled property accordingly.
3) In the handleNotification method of the GestureRecorderMediator, before your switch statement, return immediately if the Mediator is disabled.
That ought to do it.
Sounds like you're doing some interesting stuff there, just from the Mediator names. Let us know what you're up to if it's not top secret.
Re: Mediators Sequence/Priority
Reply #2 on:
September 11, 2007, 08:53:42 »
You're absolutely right. The observerMap lives in the view.
I think your suggestion is much more consistent and less intrusive (the Mediator itself holds the filter logic). Thanks.
The classes I've mentioned before are just the tip of the iceberg. We have a working Flex "Class Builder", a sort of online Powerpoint integrated with a huge multimedia database (videos, animations, simulators, etc).
The Educational Company I've been working for wouldn't allow me to share the code, but I'll try to setup some "generic" examples demonstrating how PureMVC and other useful patterns were used.
I have other questions like
Mediators using UIID, ProxyFactory combined with Inversion of Control, ChainCommands simulating workflow, TypedServices combined with Proxys, and so on, but I'll mature these doubts before starting a discussion.
Powered by SMF 2.0.15
SMF © 2006-2007, Simple Machines LLC
Content © 2006-2018, Futurescale, Inc.