http://github.com/alecmce/RobotLegsPong/blob/master/src/app/view/mediator/ScoreBoardMediator.as
You'll notice in this Mediator that the model (ScoreModel) is injected
and anytime the "change" signal is fired, it just reassigns the value
from the injected model. Now, this could have been achieved just as
easily by sending a ScoreVO along with the signal...
Does anyone have an argument why one approach is better than the
other? Or is it just preference? (I like the injected model approach
myself...)
For sake of discussion, the other approach would be to specify that
the "changed" Signal sends uints for the left and right score:
// ScoreModel.as
public function ScoreModel()
{
_currentLeftScore = 0;
_currentRightScore = 0;
_changed = new Signal(uint, uint);
}
// ScoreBoardMediator.as
private function onScoreChanged(currentLeftScore:uint,
currentRightScore:uint):void
...
I want to highlight the fact that you can send multiple objects
through a Signal without having to wrap them in a value object class.
Robert
// ScoreModel
_changed = new Signal(Score);
...
public function incrementRightScore():void
{
_currentRightScore++;
_changed.dispatch(this);