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);
regards
#1 Posted by Till Schneidere... Support staff on 28 May, 2010 09:45 AM
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 Posted by Joel Hooks Support staff on 28 May, 2010 03:03 PM
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.
Stray closed this discussion on 16 Feb, 2011 04:51 PM.