efficiently updating the model

kevin.dowd's Avatar


28 May, 2010 06:13 AM

I have a video class and need to update my model with the current time of the video - this changes
approx every 250 milliseconds.

The video class has a custom event in which it sends out when the current time of the video.

Is there a super efficient way within the framework of updating the model from the mediator - I currently
use the following but am concerned about the overhead.

commandMap.mapEvent(MediaPlayerTimeEvent.CURRENT_TIME_CHANGED, CurrentTimeCommand, MediaPlayerTimeEvent, false);


  1. Support Staff 1 Posted by Till Schneidere... on 28 May, 2010 09:45 AM

    Till Schneidereit's Avatar

    That's exactly how you should do it: The controller (your command)
    reacts to the change in the input (your view/ mediator) by updating
    the model.

    I'm not sure if by efficiency you mean having low computational
    overhead. If so, rest assured: Updating the model once every 250ms
    isn't something you need to worry about when it comes to performance.

    If, on the other hand, you're concerned about having too much
    boiler-plate code, then you might consider using bindings to
    automatically update the model. I'm not sure if that's the right thing
    to do, though: In a command, you can add validation logic should the
    need for that arise. With bindings, you'd have to add that logic in
    the model.

  2. Support Staff 2 Posted by Joel Hooks on 28 May, 2010 03:03 PM

    Joel Hooks's Avatar

    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.

  3. Stray closed this discussion on 16 Feb, 2011 04:51 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? 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