tag:robotlegs.tenderapp.com,2009-10-18:/discussions/suggestions/22-efficiently-updating-the-modelRobotlegs: Discussion 2012-01-16T15:43:06Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/17976822010-05-28T06:13:27Z2010-05-28T06:13:29Zefficiently updating the model<div><p>I have a video class and need to update my model with the
current time of the video - this changes<br>
approx every 250 milliseconds.</p>
<p>The video class has a custom event in which it sends out when
the current time of the video.</p>
<p>Is there a super efficient way within the framework of updating
the model from the mediator - I currently<br>
use the following but am concerned about the overhead.</p>
<p>commandMap.mapEvent(MediaPlayerTimeEvent.CURRENT_TIME_CHANGED,
CurrentTimeCommand, MediaPlayerTimeEvent, false);</p>
<p>regards</p></div>kevin.dowdtag:robotlegs.tenderapp.com,2009-10-18:Comment/17976822010-05-28T09:45:48Z2010-05-28T09:45:48Zefficiently updating the model<div><p>That's exactly how you should do it: The controller (your
command)<br>
reacts to the change in the input (your view/ mediator) by
updating<br>
the model.</p>
<p>I'm not sure if by efficiency you mean having low
computational<br>
overhead. If so, rest assured: Updating the model once every
250ms<br>
isn't something you need to worry about when it comes to
performance.</p>
<p>If, on the other hand, you're concerned about having too
much<br>
boiler-plate code, then you might consider using bindings to<br>
automatically update the model. I'm not sure if that's the right
thing<br>
to do, though: In a command, you can add validation logic should
the<br>
need for that arise. With bindings, you'd have to add that logic
in<br>
the model.</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/17976822010-05-28T15:03:43Z2010-05-28T15:03:43Zefficiently updating the model<div><p>I think the most efficient approach would be to inject the model
directly into the mediator. It would eliminate the minimal
computational overhead of binding or the command cycle, as well as
cutting down the overall code.</p></div>Joel Hooks