PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: valley on October 31, 2008, 03:00:31



Title: Where to put a Timer within a PureMVC Application
Post by: valley on October 31, 2008, 03:00:31
Hi there,

i've built a "normal" PureMVC-based Application.
Now i have the extension, that every minute the loaded XML data (accessible over a Proxy) has to
be parsed and data that is bound to the current time slot should be made graphical visible in the
view component.
The only question i have is: Where in this PureMVC application should the Timer be created and run, View,
Controller or Proxy ?

Thank you for your help.
Best regards
valley


Title: Re: Where to put a Timer within a PureMVC Application
Post by: Jason MacDonald on October 31, 2008, 05:41:12
Proxy, it is responsible for the retrieval and parsing of the XML. Then have it send a notification to update the view with the new data.


Title: Re: Where to put a Timer within a PureMVC Application
Post by: marek on November 07, 2008, 07:02:51
Based on my understanding of pureMVC architecture I do agree with jasonmac. I was struggling with similar problem at the beginning there for can see few possible solutions.
1.   Timer could be a integral part of proxy and could be start/stop by command depending on view behaviour for different part of application. Let’s say you have a rss reader component that allows you to switch between feeds and personalize timer delay. That option works for me if I wish my proxy instance to send a notification with data to my view every period of time.
However…
2.   Also reasonable it seems to create timer within the view and send notification for update a view every period of time especially if you wish to have additional view behaviour fired like small preloader every   time you ask for new data. That approach also doesn’t force you to send notification to the proxy once view “is closed” by user. You just need to make sure that you remove timer ‘on close’
3.   Another option  that might work for me is to create TimerProxy that could handle lot of different actions depending on dataflow, user or other actors behaviour based and public fields that could be modified externally. That seems be quite good approach if you wish to keep all sending notifications related to your timer in one place.

I am not sure that my ideas are good enough. I am new pureMVC user as well so still learning. However If I understand your problem… XMLDataProxy seems to be cool place to have a timer itself it is just a simple application. ^^


Title: Re: Where to put a Timer within a PureMVC Application
Post by: puremvc on November 07, 2008, 06:59:19
You could do it either way. The model could emit notifications at timed intervals or your view could query the model at timed intervals.

Either way is equally acceptable.

-=Cliff>


Title: Re: Where to put a Timer within a PureMVC Application
Post by: PieterGrobler on November 11, 2008, 07:21:51
What if you have a variable number of proxies (that change dynamically), that need to react on a global timer event? Since they don't listen, what would be the best approach in this case?


Title: Re: Where to put a Timer within a PureMVC Application
Post by: puremvc on November 11, 2008, 08:07:45
Have the Timer call a method on the proxy.
-=Cliff>